File size: 1,086 Bytes
f122d9d
a4583a7
 
a020d2f
9bcfd60
 
 
f122d9d
844f26f
f122d9d
 
844f26f
 
f122d9d
 
bbaff74
c9037da
f122d9d
 
 
 
 
844f26f
 
6089d8d
844f26f
2462f34
f122d9d
 
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
import gradio as gr
import os

from rag_langgraph import run_multi_agent

os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_PROJECT"] = "langgraph-multi-agent"

def invoke(openai_api_key, topic, word_count=1000):
    if (openai_api_key == ""):
        raise gr.Error("OpenAI API Key is required.")
    if (topic == ""):
        raise gr.Error("Topic is required.")
        
    os.environ["OPENAI_API_KEY"] = openai_api_key
   
    return run_multi_agent(topic, word_count)

gr.close_all()

demo = gr.Interface(fn = invoke, 
                    inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
                              gr.Textbox(label = "Topic", value=os.environ["TOPIC"], lines = 1),
                              gr.Number(label = "Word Count", value=1000, minimum=500, maximum=5000)],
                    outputs = [gr.Textbox(label = "Generated Blog Post", value=os.environ["OUTPUT"])],
                    title = "Multi-Agent RAG: Blog Post Generation",
                    description = os.environ["DESCRIPTION"])

demo.launch()