Преглед на файлове

fix: 修复AI工具调用解析错误 - tc.index改为tc.get('index')

kinglee преди 2 дни
родител
ревизия
041c79d4f7
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      app/routes/ai_routes.py

+ 1 - 1
app/routes/ai_routes.py

@@ -496,7 +496,7 @@ def analysis_chat():
                                             tc_chunk = delta['tool_calls']
                                             tc_chunk = delta['tool_calls']
                                             print(f"Chunk {chunk_count}: tool_calls received: {json.dumps(tc_chunk, ensure_ascii=False)[:200]}")
                                             print(f"Chunk {chunk_count}: tool_calls received: {json.dumps(tc_chunk, ensure_ascii=False)[:200]}")
                                             for tc in tc_chunk:
                                             for tc in tc_chunk:
-                                                index = tc.index
+                                                index = tc.get('index', 0)
                                                 if index >= len(tool_calls_buffer):
                                                 if index >= len(tool_calls_buffer):
                                                     tool_calls_buffer.append({'id': '', 'type': 'function', 'function': {'name': '', 'arguments': ''}})
                                                     tool_calls_buffer.append({'id': '', 'type': 'function', 'function': {'name': '', 'arguments': ''}})