bstraehle commited on
Commit
f122d9d
1 Parent(s): ed2b6e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import agentops, os
3
+
4
+ from crew import get_crew
5
+
6
+ LLM = "gpt-4o"
7
+
8
+ def invoke(openai_api_key, topic, word_count=500):
9
+ if (openai_api_key == ""):
10
+ raise gr.Error("OpenAI API Key is required.")
11
+ if (topic == ""):
12
+ raise gr.Error("Topic is required.")
13
+
14
+ #agentops.init(os.environ["AGENTOPS_API_KEY"])
15
+
16
+ os.environ["OPENAI_API_KEY"] = openai_api_key
17
+
18
+ result = get_crew(LLM).kickoff(inputs={"topic": topic, "word_count": word_count})
19
+
20
+ return result
21
+
22
+ gr.close_all()
23
+
24
+ demo = gr.Interface(fn = invoke,
25
+ inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
26
+ gr.Textbox(label = "Topic", value=os.environ["TOPIC"], lines = 1),
27
+ gr.Number(label = "Word Count", value=1000, minimum=500, maximum=5000)],
28
+ outputs = [gr.Markdown(label = "Generated Blog Post", value=os.environ["OUTPUT"])],
29
+ title = "Multi-Agent RAG: Blog Post Generation",
30
+ description = os.environ["DESCRIPTION"])
31
+
32
+ demo.launch()