bstraehle commited on
Commit
0133f13
1 Parent(s): 8069b5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- import os, threading
3
 
4
  from multi_agent import run_multi_agent
5
 
@@ -7,16 +7,16 @@ lock = threading.Lock()
7
 
8
  LLM = "gpt-4o"
9
 
10
- def invoke(openai_api_key, message):
11
  if not openai_api_key:
12
  raise gr.Error("OpenAI API Key is required.")
13
 
14
- if not message:
15
- raise gr.Error("Message is required.")
16
 
17
  with lock:
18
  os.environ["OPENAI_API_KEY"] = openai_api_key
19
- result = run_multi_agent(LLM, message)
20
  del os.environ["OPENAI_API_KEY"]
21
  return result
22
 
@@ -24,8 +24,8 @@ gr.close_all()
24
 
25
  demo = gr.Interface(fn = invoke,
26
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
27
- gr.Textbox(label = "Message", value = "Today is 06/03/2024. Create a plot showing stock gain YTD for NVDA and TLSA. Make sure the code is in markdown code block and save the figure to a file ytd_stock_gains.png.")],
28
- outputs = [gr.Markdown(label = "Result", value=os.environ["OUTPUT"], sanitize_html=False)],
29
  title = "Multi-Agent AI: Financial Analysis",
30
  description = os.environ["DESCRIPTION"])
31
 
 
1
  import gradio as gr
2
+ import datetime, os, threading
3
 
4
  from multi_agent import run_multi_agent
5
 
 
7
 
8
  LLM = "gpt-4o"
9
 
10
+ def invoke(openai_api_key, task):
11
  if not openai_api_key:
12
  raise gr.Error("OpenAI API Key is required.")
13
 
14
+ if not task:
15
+ raise gr.Error("Task is required.")
16
 
17
  with lock:
18
  os.environ["OPENAI_API_KEY"] = openai_api_key
19
+ result = run_multi_agent(LLM, task)
20
  del os.environ["OPENAI_API_KEY"]
21
  return result
22
 
 
24
 
25
  demo = gr.Interface(fn = invoke,
26
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
27
+ gr.Textbox(label = "Task", value = "f"Today is {datetime.date.today()}. {value=os.environ["INPUT"]}")],
28
+ outputs = [gr.Markdown(label = "Output", value = os.environ["OUTPUT"])],
29
  title = "Multi-Agent AI: Financial Analysis",
30
  description = os.environ["DESCRIPTION"])
31