Response Not Returned When Combining Streaming and...
# support
u
I am developing a Voice call AI assistant that utilizes the tools calling (function call) feature in vapi to add additional details that my custom LLM will use in processing user requests. My custom LLM points to my node setup in Buildship (a no-code api dev environment). When I call the OpenAI streaming method alone, it returns the response correctly for the assistant to voice. However, whenever I add tools to the request body as part of the data to send to OpenAI, it doesn't return any response (content received is null). The “finish_reason” usually points to tool_calls. Here is a log excerpt for reference: ` `{ "_chatCompletions": [ { "choices": [ { "message": { "role": "assistant", "tool_calls": [ { "id": "call_u14L2", "type": "function", "function": { "name": "THINKING", "arguments": "{}" } } ], "content": null }, "finish_reason": "tool_calls", "logprobs": null, "index": 0 } ], "created": 1717, "id": "chatcmpl-97l", "model": "gpt-3.5-turbo-0125", "object": "chat.completion" } ], }`` Below is the code I am using on Buildship. It works correctly without
tools
, but my intention is to include tool calls as part of the data sent to OpenAI: import OpenAI from 'openai'; export default async ({ openaiSecret, model, temperature, messages, max_tokens }, { logging, req: ctx }, ) => { const openai = new OpenAI({ apiKey: openaiSecret }); const tools = ctx.request.body.tools try { const completion = await openai.beta.chat.completions.stream({ model, temperature, messages, max_tokens, stream: true, tools }); return completion; } catch (error) { logging.log(error); return ''; } }; Could you please provide guidance on why the response is not being returned when
tools
are included and how to resolve this issue?
v
message has been deleted
u
@User, @User pls i need support on this issue. Could you help out?
s
Can you send me the final response that you are sending back to the Vapi?
u
Here is the final response my Buildhsip node is sending back to Vapi. When I send a request to OpenAI without any 'tools', I get a proper response, and Vapi voices it correctly. Here’s an example of such a response: { "_chatCompletions": [ { "model": "gpt-3.5-turbo-0125", "created": 1718101574, "id": "chatcmpl-9YszeAnF....", "object": "chat.completion", "choices": [ { "index": 0, "finish_reason": "stop", "logprobs": null, "message": { "role": "assistant", "content": "Phones be a strange contraption to a pirate like meself.\n\nAhoy matey! Phones be a curious device, but not as valuable as treasure! What be yer interest in these gadgets of the modern world?" } } ] } ] } However, when I add 'tools' to the request, OpenAI doesn’t return any content, and the response indicates a 'finish_reason' of 'tool_calls'. Here’s an example of that response: Response with tools: { "_chatCompletions": [ { "choices": [ { "message": { "role": "assistant", "tool_calls": [ { "id": "call_u14L2", "type": "function", "function": { "name": "INTERNAL_THINKING", "arguments": "{}" } } ], "content": null }, "finish_reason": "tool_calls", "logprobs": null, "index": 0 } ], "created": 1718135857, "id": "chatcmpl-9Z1m7l", "model": "gpt-3.5-turbo-0125", "object": "chat.completion" } ] }
s
3 Views