CoolFace
Apppublic

Zylora/multi-agent-ai-autogen-coding

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py34 linesDownload Raw Back to root
1import gradio as gr2import datetime, os, threading3 4from multi_agent import run_multi_agent5 6lock = threading.Lock()7 8LLM = "gpt-4o"9 10def 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    raise gr.Error("Please clone space due to local code execution.")18    19    with lock:20        os.environ["OPENAI_API_KEY"] = openai_api_key21        result = run_multi_agent(LLM, task)22        del os.environ["OPENAI_API_KEY"]23        return result24 25gr.close_all()26 27demo = gr.Interface(fn = invoke, 28                    inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),29                              gr.Textbox(label = "Task", value = f"Today is {datetime.date.today()}. {os.environ['INPUT']}")],30                    outputs = [gr.Markdown(label = "Output", value = os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)],31                    title = "Multi-Agent AI: Coding",32                    description = os.environ["DESCRIPTION"])33 34demo.launch()