bstraehle commited on
Commit
b5a97de
·
verified ·
1 Parent(s): 67b3b6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -3,6 +3,7 @@
3
  # 1. Gradio session / multi-user thread
4
  # 2. Function calling - https://platform.openai.com/docs/assistants/tools/function-calling
5
  # - Date tool
 
6
  # - Web scraping tool (Tavily API)
7
 
8
  # Reference:
@@ -44,7 +45,7 @@ def create_assistant(client):
44
  ],
45
  )
46
 
47
- show_json("assistant", assistant)
48
 
49
  return assistant
50
 
@@ -53,14 +54,14 @@ def load_assistant(client):
53
 
54
  assistant = client.beta.assistants.retrieve(ASSISTANT_ID)
55
 
56
- show_json("assistant", assistant)
57
 
58
  return assistant
59
 
60
  def create_thread(client):
61
  thread = client.beta.threads.create()
62
 
63
- show_json("thread", thread)
64
 
65
  return thread
66
 
@@ -71,7 +72,7 @@ def create_message(client, thread, msg):
71
  content=msg,
72
  )
73
 
74
- show_json("message", message)
75
 
76
  return message
77
 
@@ -81,7 +82,7 @@ def create_run(client, assistant, thread):
81
  thread_id=thread.id,
82
  )
83
 
84
- show_json("run", run)
85
 
86
  return run
87
 
@@ -94,7 +95,7 @@ def wait_on_run(client, thread, run):
94
 
95
  time.sleep(0.25)
96
 
97
- show_json("run", run)
98
 
99
  return run
100
 
@@ -105,7 +106,7 @@ def get_run_steps(client, thread, run):
105
  order="asc",
106
  )
107
 
108
- show_json("run_steps", run_steps)
109
 
110
  return run_steps
111
 
@@ -127,16 +128,14 @@ def get_run_step_details(run_steps):
127
 
128
  for step in run_steps.data:
129
  step_details = step.step_details
 
130
  run_step_details.append(step_details)
131
 
132
- show_json("step_details", step_details)
133
-
134
  ###
135
  if hasattr(step_details, "tool_calls"):
136
  for tool_call in step_details.tool_calls:
137
- result = execute_tool_call(tool_call)
138
-
139
  show_json("tool_call", tool_call)
 
140
  ###
141
 
142
  return run_step_details
 
3
  # 1. Gradio session / multi-user thread
4
  # 2. Function calling - https://platform.openai.com/docs/assistants/tools/function-calling
5
  # - Date tool
6
+ # - yfinance
7
  # - Web scraping tool (Tavily API)
8
 
9
  # Reference:
 
45
  ],
46
  )
47
 
48
+ #show_json("assistant", assistant)
49
 
50
  return assistant
51
 
 
54
 
55
  assistant = client.beta.assistants.retrieve(ASSISTANT_ID)
56
 
57
+ #show_json("assistant", assistant)
58
 
59
  return assistant
60
 
61
  def create_thread(client):
62
  thread = client.beta.threads.create()
63
 
64
+ #show_json("thread", thread)
65
 
66
  return thread
67
 
 
72
  content=msg,
73
  )
74
 
75
+ #show_json("message", message)
76
 
77
  return message
78
 
 
82
  thread_id=thread.id,
83
  )
84
 
85
+ #show_json("run", run)
86
 
87
  return run
88
 
 
95
 
96
  time.sleep(0.25)
97
 
98
+ #show_json("run", run)
99
 
100
  return run
101
 
 
106
  order="asc",
107
  )
108
 
109
+ #show_json("run_steps", run_steps)
110
 
111
  return run_steps
112
 
 
128
 
129
  for step in run_steps.data:
130
  step_details = step.step_details
131
+ show_json("step_details", step_details)
132
  run_step_details.append(step_details)
133
 
 
 
134
  ###
135
  if hasattr(step_details, "tool_calls"):
136
  for tool_call in step_details.tool_calls:
 
 
137
  show_json("tool_call", tool_call)
138
+ result = execute_tool_call(tool_call)
139
  ###
140
 
141
  return run_step_details