From 83bf68d318b496da06ae8764dff213ae4cfd06da Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 2 Mar 2024 19:10:20 +0800 Subject: [PATCH] updated tool run update --- implementation/agent.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/implementation/agent.py b/implementation/agent.py index c480f65..1061c0d 100644 --- a/implementation/agent.py +++ b/implementation/agent.py @@ -83,18 +83,19 @@ def process_call(tool_call): agent_complete = True elif run.status == "requires_action": tool_calls = run.required_action.submit_tool_outputs.tool_calls + tool_outputs = [] for tool_call in tool_calls: output = process_call(tool_call) - run = client.beta.threads.runs.submit_tool_outputs( - thread_id=thread.id, - run_id=run.id, - tool_outputs=[ - { - "tool_call_id": tool_call.id, - "output": output, - } - ] - ) + tool_outputs.append({ + "tool_call_id": tool_call.id, + "output": output, + }) + assert len(tool_outputs) == len(tool_calls) + run = client.beta.threads.runs.submit_tool_outputs( + thread_id=thread.id, + run_id=run.id, + tool_outputs=tool_outputs + ) if not agent_complete: raise TimeoutError("Agent did not complete in time") if not self.category: