bstraehle commited on
Commit
8b7dba2
1 Parent(s): 62e051d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -2,7 +2,6 @@
2
  #
3
  # 1. Gradio session / multi-user thread
4
  # 2. Function calling - https://platform.openai.com/docs/assistants/tools/function-calling
5
- # - get_stock_price - yfinance
6
 
7
  # Reference:
8
  #
@@ -28,10 +27,8 @@ client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
28
  assistant, thread = None, None
29
 
30
  def today_tool(text: str) -> str:
31
- """Returns today's date.
32
- Use this function for any questions related to knowing today's date.
33
- There is no input.
34
- This function always returns today's date."""
35
  return str(date.today())
36
 
37
  def yf_download_tool(tickers: List[str], start_date: date, end_date: date) -> pd.DataFrame:
@@ -132,7 +129,8 @@ def get_run_steps(client, thread, run):
132
  def execute_tool_call(tool_call):
133
  name = tool_call.function.name
134
  args = json.loads(tool_call.function.arguments)
135
-
 
136
  return tools[name](**args)
137
 
138
  def execute_tool_calls(run_steps):
@@ -221,6 +219,7 @@ def chat(message, history):
221
  run_steps = get_run_steps(client, thread, run)
222
  tool_call_id, tool_call_result = execute_tool_calls(run_steps)
223
  ###
 
224
  if tool_call_id:
225
  print("### tool_call_id=" + tool_call_id)
226
  print(tool_call_result)
@@ -240,6 +239,7 @@ def chat(message, history):
240
  run = wait_on_run(client, thread, run)
241
  run_steps = get_run_steps(client, thread, run)
242
  tool_call_id, tool_call_result = execute_tool_calls(run_steps)
 
243
  ###
244
 
245
  messages = get_messages(client, thread)
 
2
  #
3
  # 1. Gradio session / multi-user thread
4
  # 2. Function calling - https://platform.openai.com/docs/assistants/tools/function-calling
 
5
 
6
  # Reference:
7
  #
 
27
  assistant, thread = None, None
28
 
29
  def today_tool(text: str) -> str:
30
+ """Returns today's date. Use this function for any questions related to knowing today's date.
31
+ There is no input. This function always returns today's date."""
 
 
32
  return str(date.today())
33
 
34
  def yf_download_tool(tickers: List[str], start_date: date, end_date: date) -> pd.DataFrame:
 
129
  def execute_tool_call(tool_call):
130
  name = tool_call.function.name
131
  args = json.loads(tool_call.function.arguments)
132
+ print(f"Executing tool: {tools[name]}")
133
+
134
  return tools[name](**args)
135
 
136
  def execute_tool_calls(run_steps):
 
219
  run_steps = get_run_steps(client, thread, run)
220
  tool_call_id, tool_call_result = execute_tool_calls(run_steps)
221
  ###
222
+ """
223
  if tool_call_id:
224
  print("### tool_call_id=" + tool_call_id)
225
  print(tool_call_result)
 
239
  run = wait_on_run(client, thread, run)
240
  run_steps = get_run_steps(client, thread, run)
241
  tool_call_id, tool_call_result = execute_tool_calls(run_steps)
242
+ """
243
  ###
244
 
245
  messages = get_messages(client, thread)