bstraehle commited on
Commit
8d80ad9
1 Parent(s): 23028bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -159,14 +159,13 @@ def wait_on_run(client, thread, run):
159
 
160
  return run
161
 
162
- ###
163
- def execute_tool_call(tool_call):
164
  name = tool_call.function.name
165
  args = json.loads(tool_call.function.arguments)
 
166
  print(f"{name}, {args}")
167
 
168
- #return tools[name](**args)
169
- ###
170
 
171
  def list_run_steps(client, thread, run):
172
  run_steps = client.beta.threads.runs.steps.list(
@@ -181,9 +180,12 @@ def list_run_steps(client, thread, run):
181
 
182
  if not hasattr(step_details, "tool_calls"):
183
  break
 
 
 
184
 
185
  for tool_call in step_details.tool_calls:
186
- result = execute_tool_call(tool_call)
187
 
188
  return run_steps
189
 
 
159
 
160
  return run
161
 
162
+ def execute_tool_call(tools, tool_call):
 
163
  name = tool_call.function.name
164
  args = json.loads(tool_call.function.arguments)
165
+
166
  print(f"{name}, {args}")
167
 
168
+ return tools[name](**args)
 
169
 
170
  def list_run_steps(client, thread, run):
171
  run_steps = client.beta.threads.runs.steps.list(
 
180
 
181
  if not hasattr(step_details, "tool_calls"):
182
  break
183
+
184
+ #tool_schemas = [function_to_schema(tool) for tool in current_agent.tools]
185
+ tools = {tool.__name__: tool for tool in get_current_agent().tools}
186
 
187
  for tool_call in step_details.tool_calls:
188
+ result = execute_tool_call(tools, tool_call)
189
 
190
  return run_steps
191