File size: 1,104 Bytes
7aa6874
0133f13
7aa6874
 
 
 
 
c87a829
7aa6874
0133f13
dd9a7ec
7aa6874
 
0133f13
 
cf287d2
b062c3e
c87a829
7aa6874
 
0133f13
7aa6874
 
 
 
 
 
 
752352d
a52bed3
d8fdcda
7aa6874
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import datetime, 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.")

    raise gr.Error("Please clone space due to local code execution.")
    
    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 = f"Today is {datetime.date.today()}. {os.environ['INPUT']}")],
                    outputs = [gr.Markdown(label = "Output", value = os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)],
                    title = "Multi-Agent AI: Coding",
                    description = os.environ["DESCRIPTION"])

demo.launch()