Spaces:
Sleeping
Sleeping
File size: 1,156 Bytes
242965f 77c225f e8da79a fc7e5cb 5e8e222 bb7709c e8da79a 84e183d e8da79a 7cfc686 bf7f003 c8b3dd8 37d316b c8b3dd8 5e2d6bd c74f41d 5e2d6bd e8da79a be81de0 51fad07 98ceacb 27cc418 2dead2b 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 31 32 33 34 35 36 |
import gradio as gr
import agentops, os
from crew import get_crew
LLM = "gpt-4o"
def invoke(openai_api_key, topic, word_count=500):
if (openai_api_key == ""):
raise gr.Error("OpenAI API Key is required.")
if (topic == ""):
raise gr.Error("Topic is required.")
agentops.init(os.environ["AGENTOPS_API_KEY"])
os.environ["OPENAI_API_KEY"] = openai_api_key
result = get_crew(LLM).kickoff(inputs={"topic": topic, "word_count": word_count})
print("###")
print(result)
print("###")
return result
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=500, minimum=500, maximum=5000)],
outputs = [gr.Markdown(label = "Generated Blog Post", value=os.environ["OUTPUT"])],
title = "Multi-Agent RAG: Blog Post Generation",
description = os.environ["DESCRIPTION"])
demo.launch() |