Bläddra i källkod

fix: extract tool calls correctly while arguments is empty (#6503)

sino 9 månader sedan
förälder
incheckning
dfb6f4fec6
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10 2
      api/core/agent/fc_agent_runner.py

+ 10 - 2
api/core/agent/fc_agent_runner.py

@@ -342,10 +342,14 @@ class FunctionCallAgentRunner(BaseAgentRunner):
         """
         tool_calls = []
         for prompt_message in llm_result_chunk.delta.message.tool_calls:
+            args = {}
+            if prompt_message.function.arguments != '':
+                args = json.loads(prompt_message.function.arguments)
+
             tool_calls.append((
                 prompt_message.id,
                 prompt_message.function.name,
-                json.loads(prompt_message.function.arguments),
+                args,
             ))
 
         return tool_calls
@@ -359,10 +363,14 @@ class FunctionCallAgentRunner(BaseAgentRunner):
         """
         tool_calls = []
         for prompt_message in llm_result.message.tool_calls:
+            args = {}
+            if prompt_message.function.arguments != '':
+                args = json.loads(prompt_message.function.arguments)
+
             tool_calls.append((
                 prompt_message.id,
                 prompt_message.function.name,
-                json.loads(prompt_message.function.arguments),
+                args,
             ))
 
         return tool_calls