fix: f the stream resp

This commit is contained in:
Junyan Qin
2025-02-11 21:19:15 +08:00
parent fabf93f741
commit e89c6b68c9
+4 -1
View File
@@ -61,7 +61,7 @@ class OpenAIChatCompletions(requester.LLMAPIRequester):
async for chunk in resp_gen: async for chunk in resp_gen:
# print(chunk) # print(chunk)
if not chunk: if not chunk or not chunk.id or not chunk.choices or not chunk.choices[0] or not chunk.choices[0].delta:
continue continue
if chunk.choices[0].delta.content is not None: if chunk.choices[0].delta.content is not None:
@@ -76,6 +76,9 @@ class OpenAIChatCompletions(requester.LLMAPIRequester):
else: else:
tool_calls.append(tool_call) tool_calls.append(tool_call)
if chunk.choices[0].finish_reason is not None:
break
real_tool_calls = [] real_tool_calls = []
for tc in tool_calls: for tc in tool_calls: