bstraehle's picture
Update app.py
dd9a7ec verified
raw
history blame
1.04 kB
import gradio as gr
import os, threading
from multi_agent import run_multi_agent
lock = threading.Lock()
LLM = "gpt-4o"
def invoke(openai_api_key, task):
if not openai_api_key:
raise gr.Error("OpenAI API Key is required.")
if not task:
raise gr.Error("Task is required.")
with lock:
os.environ["OPENAI_API_KEY"] = openai_api_key
result = run_multi_agent(LLM, task)
del os.environ["OPENAI_API_KEY"]
return result
gr.close_all()
demo = gr.Interface(fn = invoke,
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
gr.Textbox(label = "Task", value = "Write a blogpost about the stock price performance of Nvidia in the past month. Today's date is 2024-06-03.")],
outputs = [gr.Textbox(label = "Result", value=os.environ["OUTPUT"])],
title = "Multi-Agent AI: Financial Analysis",
description = os.environ["DESCRIPTION"])
demo.launch()