Open zandko opened 9 months ago
data.append({ 'sources': functionResponse.sources }); If the string is too long, it will be truncated.
const data = new experimental_StreamData(); const stream = OpenAIStream(response, { experimental_onToolCall: async ( call: ToolCallPayload, appendToolCallMessage, ) => { // ... for (const toolCall of call.tools) { const functionName = toolCall.func.name; const functionToCall = availableFunctions[functionName]; const functionArgs = JSON.parse(toolCall.func.arguments as unknown as string); const functionResponse = await functionToCall(parseNestedJSON(functionArgs)); if (functionResponse.sources !== 'NONE') { data.append({ 'sources': functionResponse.sources }); } const newMessages = appendToolCallMessage({ tool_call_id: toolCall.id, function_name: functionName, tool_call_result: functionResponse.result, }); return openai.chat.completions.create({ ...defaultOptions, messages: [...messages, ...newMessages], model: LanguageModel.GPT3_5_16K, stream: true, tools, temperature: 0.2, tool_choice: 'auto', }); } }, onCompletion(completion) { console.log('completion', completion); }, onFinal(completion) { data.close(); }, experimental_streamData: true, }); return new StreamingTextResponse(stream, { headers: { ...ResponseHeaders } }, data);
No response
How long of a string are we talking about here?
Description
data.append({ 'sources': functionResponse.sources }); If the string is too long, it will be truncated.
Code example
Additional context
No response