(req, res)
| 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 段 |
nothing calls this directly
no test coverage detected