bstraehle commited on
Commit
db5c6e9
1 Parent(s): 8529465

Update assistants.py

Browse files
Files changed (1) hide show
  1. assistants.py +5 -6
assistants.py CHANGED
@@ -140,7 +140,7 @@ def get_run_steps(thread, run):
140
  print(get_json("run_steps", run_steps))
141
  return run_steps
142
 
143
- def execute_tool_call(tool_call):
144
  name = tool_call.function.name
145
  args = {}
146
 
@@ -152,8 +152,6 @@ def execute_tool_call(tool_call):
152
  args = json.loads(args_json)
153
  except json.JSONDecodeError as e:
154
  print(f"Error parsing function name '{name}' function args '{args_json}': {e}")
155
-
156
- gr.Info(f"Function: {name}, args: {args}", duration=30)
157
 
158
  return tools[name](**args)
159
 
@@ -167,8 +165,6 @@ def execute_tool_calls(run_steps):
167
 
168
  if step.usage:
169
  gr.Info(f"Step: {step_details.type}, {get_json('usage', step.usage)}", duration=30)
170
- else:
171
- gr.Info(f"Step: {step_details.type}", duration=30)
172
 
173
  if hasattr(step_details, "tool_calls"):
174
  for tool_call in step_details.tool_calls:
@@ -176,7 +172,10 @@ def execute_tool_calls(run_steps):
176
 
177
  if hasattr(tool_call, "function"):
178
  tool_call_ids.append(tool_call.id)
179
- tool_call_results.append(execute_tool_call(tool_call))
 
 
 
180
  else:
181
  gr.Info(f"Tool: {tool_call.type}", duration=30)
182
 
 
140
  print(get_json("run_steps", run_steps))
141
  return run_steps
142
 
143
+ def execute_tool_call(step, tool_call):
144
  name = tool_call.function.name
145
  args = {}
146
 
 
152
  args = json.loads(args_json)
153
  except json.JSONDecodeError as e:
154
  print(f"Error parsing function name '{name}' function args '{args_json}': {e}")
 
 
155
 
156
  return tools[name](**args)
157
 
 
165
 
166
  if step.usage:
167
  gr.Info(f"Step: {step_details.type}, {get_json('usage', step.usage)}", duration=30)
 
 
168
 
169
  if hasattr(step_details, "tool_calls"):
170
  for tool_call in step_details.tool_calls:
 
172
 
173
  if hasattr(tool_call, "function"):
174
  tool_call_ids.append(tool_call.id)
175
+ tool_call_results.append(execute_tool_call(step, tool_call))
176
+
177
+ if step.usage:
178
+ gr.Info(f"Function: {tool_call.function.name}, args: {tool_call.function.arguments}", duration=30)
179
  else:
180
  gr.Info(f"Tool: {tool_call.type}", duration=30)
181