-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hi, it seems that since v3.19.0, the function parameter chunks fetched using the completions API of the synchronous OpenAI API wrapper with stream=True
are duplicated, resulting in invalid JSON, e.g. {"{"processprocess_id_id":2}:2}
instead of just {"process_id":2}
. The "normal" responses work fine though.
I use the following logic to concatenate the chunks, which worked before v3.19.0:
final_tool_calls = {}
for chunk in response:
delta = chunk.choices[0].delta
if delta.tool_calls:
for tool_call in delta.tool_calls:
index = tool_call.index
if index not in final_tool_calls:
final_tool_calls[index] = tool_call
final_tool_calls[index].function.arguments += tool_call.function.arguments
I suppose the following line causes the issue. It does exactly the same as my code, including manipulating the original function object. Maybe that should be cloned first?
posthog-python/posthog/ai/openai/openai.py
Line 139 in 8331af7
accumulated_tools[index].function.arguments += tool_call.function.arguments |
Metadata
Metadata
Assignees
Labels
No labels