File size: 1,075 Bytes
242965f
c74f41d
e8da79a
fc7e5cb
e8da79a
7cfc686
e8da79a
 
7cfc686
 
c74f41d
e8da79a
7cfc686
c74f41d
 
7cfc686
e8da79a
 
 
 
 
 
 
 
c2d69f4
d015f88
7cfc686
e8da79a
 
 
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
import gradio as gr
import agentops, openai, os

from crew import get_crew

def invoke(openai_api_key, topic):
    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

    agentops.init(os.environ["AGENTOPS_API_KEY"])
    
    return get_crew().kickoff(inputs={"topic": topic})

description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> SDK 
                 with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""

gr.close_all()

demo = gr.Interface(fn = invoke, 
                    inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
                              gr.Textbox(label = "Topic", value="Agentic RAG", lines = 1)],
                    outputs = [gr.Textbox(label = "Output", lines = 1)],
                    title = "Agentic RAG: Research Write Article",
                    description = description)

demo.launch()