mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
* fix(provider): add missing index field to streaming tool_call deltas - Fix #6661: Streaming tool_call arguments lost when OpenAI-compatible proxy omits index field - Gemini and some proxies (e.g. Continue) don't include index field in tool_call deltas - Add default index=0 when missing to prevent ChatCompletionStreamState.handle_chunk() from rejecting chunks Fixes #6661 * fix(provider): use enumerate for multi-tool-call index assignment - Use enumerate() to assign correct index based on list position - Iterate over all choices (not just the first) for completeness - Addresses review feedback from sourcery-ai and gemini-code-assist --------- Co-authored-by: Yaohua-Leo <3067173925@qq.com> Co-authored-by: Soulter <905617992@qq.com>
This commit is contained in:
@@ -334,11 +334,15 @@ class ProviderOpenAIOfficial(Provider):
|
||||
choice = chunk.choices[0]
|
||||
delta = choice.delta
|
||||
|
||||
# siliconflow workaround
|
||||
if dtcs := delta.tool_calls:
|
||||
for tc in dtcs:
|
||||
for idx, tc in enumerate(dtcs):
|
||||
# siliconflow workaround
|
||||
if tc.function and tc.function.arguments:
|
||||
tc.type = "function"
|
||||
# Fix for #6661: Add missing 'index' field to tool_call deltas
|
||||
# Gemini and some OpenAI-compatible proxies omit this field
|
||||
if not hasattr(tc, "index") or tc.index is None:
|
||||
tc.index = idx
|
||||
try:
|
||||
state.handle_chunk(chunk)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user