import gradio as gr import agentops, os from crew import get_financial_trading_crew AGENTOPS_API_KEY = os.environ["AGENTOPS_API_KEY"] agentops.init() 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 return get_crew().kickoff(inputs={"topic": topic}) description = """Gradio UI using the OpenAI SDK with gpt-4 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()