Update app.py
Browse files
app.py
CHANGED
|
@@ -1 +1,32 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os, threading
|
| 3 |
+
|
| 4 |
+
from agent import run_agent
|
| 5 |
+
|
| 6 |
+
lock = threading.Lock()
|
| 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_agent(LLM, task)
|
| 20 |
+
del os.environ["OPENAI_API_KEY"]
|
| 21 |
+
return result
|
| 22 |
+
|
| 23 |
+
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 = "Task", value = os.environ['INPUT'])],
|
| 28 |
+
outputs = [gr.Markdown(label = "Output", value = os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)],
|
| 29 |
+
title = "Multi-Agent AI: Coding",
|
| 30 |
+
description = os.environ["DESCRIPTION"])
|
| 31 |
+
|
| 32 |
+
demo.launch()
|