Browse Source

修改agent执行时候,工具调用参数输出

xueyiming 3 hours ago
parent
commit
6597608998
1 changed files with 15 additions and 0 deletions
  1. 15 0
      pqai_agent/agents/simple_chat_agent.py

+ 15 - 0
pqai_agent/agents/simple_chat_agent.py

@@ -54,6 +54,21 @@ class SimpleOpenAICompatibleChatAgent:
             logger.debug(f"run_id[{run_id}] current step content: {message.content}")
 
             if message.tool_calls:
+                call_list = []  # 存储函数调用信息的列表
+                for tool_call in message.tool_calls:
+                    function_name = tool_call.function.name
+                    arguments = json.loads(tool_call.function.arguments)
+                    call_list.append({
+                        "name": function_name,
+                        "parameters": arguments
+                    })
+                tool_message = json.dumps(call_list, ensure_ascii=False, indent=2)
+                agent_task_detail = AgentTaskDetail()
+                agent_task_detail.executor_type = 'llm'
+                agent_task_detail.executor_name = self.model
+                agent_task_detail.output_data = tool_message
+                agent_task_detail.status = AgentTaskDetailStatus.SUCCESS.value
+                self.agent_task_details.append(agent_task_detail)
                 for tool_call in message.tool_calls:
                     function_name = tool_call.function.name
                     arguments = json.loads(tool_call.function.arguments)