bstraehle commited on
Commit
1679686
1 Parent(s): c8ee1ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -8
app.py CHANGED
@@ -58,6 +58,16 @@ def execute_refund(item_id, reason="not provided"):
58
  print("Refund execution successful!")
59
  return "Success"
60
 
 
 
 
 
 
 
 
 
 
 
61
  # Agents
62
 
63
  MODEL = "gpt-4o-mini"
@@ -169,13 +179,13 @@ def list_messages(client, thread):
169
  #show_json("messages", messages)
170
  return messages
171
 
172
- def extract_content_values(data):
173
- content_values = []
174
- for item in data.data:
175
- for content in item.content:
176
- if content.type == 'text':
177
- content_values.append(content.text.value)
178
- return content_values
179
 
180
  #
181
 
@@ -231,7 +241,15 @@ def chat(message, history, openai_api_key):
231
 
232
  messages = list_messages(_client, _thread)
233
 
234
- return extract_content_values(messages)[0]
 
 
 
 
 
 
 
 
235
 
236
  gr.ChatInterface(
237
  chat,
 
58
  print("Refund execution successful!")
59
  return "Success"
60
 
61
+ #
62
+
63
+ def execute_tool_call(tool_call, tools, agent_name):
64
+ name = tool_call.function.name
65
+ args = json.loads(tool_call.function.arguments)
66
+
67
+ print(f"{agent_name}, {name}, {args}")
68
+
69
+ return tools[name](**args) # call corresponding function with provided arguments
70
+
71
  # Agents
72
 
73
  MODEL = "gpt-4o-mini"
 
179
  #show_json("messages", messages)
180
  return messages
181
 
182
+ #def extract_content_values(data):
183
+ # content_values = []
184
+ # for item in data.data:
185
+ # for content in item.content:
186
+ # if content.type == 'text':
187
+ # content_values.append(content.text.value)
188
+ # return content_values
189
 
190
  #
191
 
 
241
 
242
  messages = list_messages(_client, _thread)
243
 
244
+ print("###")
245
+ print(message[0])
246
+ print("###")
247
+ print(message[0].content.text.value)
248
+ print("###")
249
+
250
+ # Call function
251
+
252
+ return "TODO" #extract_content_values(messages)[0]
253
 
254
  gr.ChatInterface(
255
  chat,