bstraehle commited on
Commit
4a9ad4b
1 Parent(s): e91564c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
app.py CHANGED
@@ -21,6 +21,11 @@ def transfer_to_issues_repairs_agent():
21
  """Use for issues, repairs, or refunds."""
22
  set_current_agent(issues_repairs_agent)
23
 
 
 
 
 
 
24
  #
25
 
26
  def escalate_to_human(summary):
@@ -159,12 +164,20 @@ def wait_on_run(client, thread, run):
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):
@@ -176,31 +189,13 @@ def list_run_steps(client, thread, run):
176
 
177
  for step in run_steps.data:
178
  step_details = step.step_details
179
- show_json("step_details", step_details)
180
 
181
  if not hasattr(step_details, "tool_calls"):
182
  break
183
 
184
- print("XXXXX")
185
- print(get_current_agent().tools)
186
- print("XXXXX")
187
- #print(tools)
188
- #print("XXXXX")
189
-
190
- ###
191
- tools = {}
192
- for tool in get_current_agent().tools:
193
- print("===")
194
- print(tool)
195
- print("===")
196
- print(tool.function)
197
- print("===")
198
- ###
199
-
200
- tools = {tool.function.__name__: tool.function for tool in get_current_agent().tools}
201
-
202
  for tool_call in step_details.tool_calls:
203
- result = execute_tool_call(tools, tool_call)
204
 
205
  return run_steps
206
 
 
21
  """Use for issues, repairs, or refunds."""
22
  set_current_agent(issues_repairs_agent)
23
 
24
+ tools = {"transfer_to_triage_agent": transfer_to_triage_agent,
25
+ "transfer_to_sales_agent": transfer_to_sales_agent,
26
+ "transfer_to_issues_repairs_agent": transfer_to_issues_repairs_agent,
27
+ "escalate_to_human": escalate_to_human}
28
+
29
  #
30
 
31
  def escalate_to_human(summary):
 
164
 
165
  return run
166
 
167
+ def execute_tool_call(tool_call):
168
  name = tool_call.function.name
169
  args = json.loads(tool_call.function.arguments)
170
 
171
  print(f"{name}, {args}")
172
+
173
+ global tools
174
+
175
+ print("===")
176
+ print(tools)
177
+ print("===")
178
+ print(tools[name])
179
+ print("===")
180
+
181
  return tools[name](**args)
182
 
183
  def list_run_steps(client, thread, run):
 
189
 
190
  for step in run_steps.data:
191
  step_details = step.step_details
192
+ #show_json("step_details", step_details)
193
 
194
  if not hasattr(step_details, "tool_calls"):
195
  break
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  for tool_call in step_details.tool_calls:
198
+ result = execute_tool_call(tool_call)
199
 
200
  return run_steps
201