|
import gradio as gr |
|
import os, threading |
|
|
|
from multi_agent import run_multi_agent |
|
|
|
lock = threading.Lock() |
|
|
|
LLM = "llama3-8b-8192" |
|
|
|
def invoke(groq_api_key, task): |
|
if not os.environ("GROQ_API_KEY_defualt"): |
|
if not groq_api_key: |
|
|
|
raise gr.Error("Groq API Key is required, And get it from here :(https://console.groq.com/keys)") |
|
else: |
|
os.environ["GROQ_API_KEY"] = groq_api_key |
|
else: |
|
os.environ["GROQ_API_KEY"] = os.environ("GROQ_API_KEY_defualt") |
|
if not task: |
|
raise gr.Error("Task is required.") |
|
|
|
raise gr.Error("Please clone space due to local code execution.") |
|
|
|
with lock: |
|
|
|
result = run_multi_agent(LLM, task) |
|
del os.environ["GROQ_API_KEY"] |
|
return result |
|
|
|
gr.close_all() |
|
|
|
demo = gr.Interface(fn = invoke, |
|
inputs = [gr.Textbox(label = "GROQ API KEY", type = "password", lines = 1), |
|
gr.Textbox(label = "Task", value = 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() |