bstraehle commited on
Commit
686539e
·
verified ·
1 Parent(s): 21ce7f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -246,16 +246,23 @@ def chat(message, history):
246
  print("###")
247
 
248
  # https://platform.openai.com/docs/api-reference/runs/submitToolOutputs
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  run = client.beta.threads.runs.submit_tool_outputs(
250
  thread_id=thread.id,
251
  run_id=run.id,
252
- #tool_outputs=generate_tool_outputs(tool_call_ids, tool_call_results)
253
- tool_outputs=[
254
- {
255
- "tool_call_id": tool_call_ids[0],
256
- "output": tool_call_results[0]
257
- }
258
- ]
259
  )
260
 
261
  run = wait_on_run(client, thread, run)
@@ -273,16 +280,23 @@ def chat(message, history):
273
  print("###")
274
 
275
  # https://platform.openai.com/docs/api-reference/runs/submitToolOutputs
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  run = client.beta.threads.runs.submit_tool_outputs(
277
  thread_id=thread.id,
278
  run_id=run.id,
279
- #tool_outputs=generate_tool_outputs(tool_call_ids, tool_call_results)
280
- tool_outputs=[
281
- {
282
- "tool_call_id": tool_call_ids[1],
283
- "output": tool_call_results[1].to_json()
284
- }
285
- ]
286
  )
287
 
288
  run = wait_on_run(client, thread, run)
 
246
  print("###")
247
 
248
  # https://platform.openai.com/docs/api-reference/runs/submitToolOutputs
249
+ tool_output = {}
250
+
251
+ try:
252
+ tool_output = {
253
+ "tool_call_id": tool_call_ids[0],
254
+ "output": tool_call_results[0].to_json()
255
+ }
256
+ except AttributeError:
257
+ tool_output = {
258
+ "tool_call_id": tool_call_ids[0],
259
+ "output": tool_call_results[0]
260
+ }
261
+
262
  run = client.beta.threads.runs.submit_tool_outputs(
263
  thread_id=thread.id,
264
  run_id=run.id,
265
+ tool_outputs=[tool_output]
 
 
 
 
 
 
266
  )
267
 
268
  run = wait_on_run(client, thread, run)
 
280
  print("###")
281
 
282
  # https://platform.openai.com/docs/api-reference/runs/submitToolOutputs
283
+ tool_output = {}
284
+
285
+ try:
286
+ tool_output = {
287
+ "tool_call_id": tool_call_ids[1],
288
+ "output": tool_call_results[1].to_json()
289
+ }
290
+ except AttributeError:
291
+ tool_output = {
292
+ "tool_call_id": tool_call_ids[1],
293
+ "output": tool_call_results[1]
294
+ }
295
+
296
  run = client.beta.threads.runs.submit_tool_outputs(
297
  thread_id=thread.id,
298
  run_id=run.id,
299
+ tool_outputs=[tool_output]
 
 
 
 
 
 
300
  )
301
 
302
  run = wait_on_run(client, thread, run)