MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / handleChatCompletion

Function handleChatCompletion

src/controllers/chat.js:769–801  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

767 ]
768 },
769 "finish_reason": null
770 }
771 ]
772 }
773 res.write(`data: ${JSON.stringify(headerDelta)}\n\n`)
774
775 const argsString = call.function.arguments || ''
776 for (let offset = 0; offset < argsString.length; offset += ARG_CHUNK_SIZE) {
777 const piece = argsString.slice(offset, offset + ARG_CHUNK_SIZE)
778 const argDelta = {
779 "id": `chatcmpl-${message_id}`,
780 "object": "chat.completion.chunk",
781 "created": Math.round(new Date().getTime() / 1000),
782 "choices": [
783 {
784 "index": 0,
785 "delta": {
786 "tool_calls": [
787 {
788 "index": index,
789 "function": { "arguments": piece }
790 }
791 ]
792 },
793 "finish_reason": null
794 }
795 ]
796 }
797 res.write(`data: ${JSON.stringify(argDelta)}\n\n`)
798 }
799 }
800 }
801
802 /**
803 * 处理一个 SSE data 段(已剥离 'data: ' 前缀)
804 * @param {string} dataContent - 原始 data 段

Callers

nothing calls this directly

Calls 5

sendChatRequestFunction · 0.85
setResponseHeadersFunction · 0.85
handleStreamResponseFunction · 0.85
handleNonStreamResponseFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected