fix: 修复频繁打断下生成器不会清理

This commit is contained in:
Sakura-RanChen
2026-04-22 11:24:43 +08:00
parent 8a156e99f4
commit 2a4dbdb69b
4 changed files with 131 additions and 117 deletions
@@ -74,12 +74,15 @@ class LLMProvider(LLMProviderBase):
tools=functions,
)
for chunk in stream:
delta = chunk.choices[0].delta
content = delta.content
tool_calls = delta.tool_calls
try:
for chunk in stream:
delta = chunk.choices[0].delta
content = delta.content
tool_calls = delta.tool_calls
if content:
yield content, tool_calls
elif tool_calls:
yield None, tool_calls
if content:
yield content, tool_calls
elif tool_calls:
yield None, tool_calls
finally:
stream.close()