bstraehle's picture
Update app.py
f733e39 verified
raw
history blame
1.05 kB
import gradio as gr
import agentops, os
from crew import get_crew
LLM = "gpt-4o"
def invoke(openai_api_key, topic, length):
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
return get_crew(LLM).kickoff(inputs={"topic": topic, "length": length})
gr.close_all()
demo = gr.Interface(fn = invoke,
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
gr.Textbox(label = "Topic", value="Evolution of Retrieval-Augmented Generation from Naive RAG to Agentic RAG", lines = 1),
gr.Number(label = "Words", value="2500")],
outputs = [gr.Textbox(label = "Output", lines = 1)],
title = "Multi-Agent RAG: Blog Post Generation",
description = os.environ["DESCRIPTION"])
demo.launch()