Skip to content

Commit 6ab529c

Browse files
committed
fix:处理非标聚合平台可能缺失工具调用中type字段的问题
1 parent 67950e7 commit 6ab529c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

astrbot/core/provider/sources/openai_source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,11 @@ async def _query_stream(
316316
if not choice.delta or not choice.delta.tool_calls:
317317
continue
318318
for tool_call in choice.delta.tool_calls:
319-
if hasattr(tool_call, "type") and tool_call.type in (None, ""):
319+
# 使用 getattr 处理 type 字段可能完全缺失的情况
320+
tool_type = getattr(tool_call, "type", None)
321+
if tool_type is None or tool_type == "":
320322
logger.debug(
321-
f"[{self.get_model()}] tool_call.type is empty in chunk {chunk_index} "
323+
f"[{self.get_model()}] tool_call.type is missing or empty in chunk {chunk_index} "
322324
f"(provider: {self.provider_config.get('id', 'unknown')}), "
323325
f"manually set to 'function'"
324326
)

0 commit comments

Comments
 (0)