Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	File size: 1,398 Bytes
			
			| 242965f 77c225f e8da79a fc7e5cb 5e8e222 e8da79a 0f48b51 e8da79a 0f48b51 7cfc686 c74f41d 8b55e49 c1a13e8 7cfc686 8b55e49 747a549 37d316b 77c225f c74f41d 77c225f 5e8e222 e8da79a 0f48b51 e40b271 d015f88 77c225f 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 37 38 39 40 | import gradio as gr
import agentops, os
from crew import get_crew
LLM = "gpt-4o"
def invoke(openai_api_key, serper_api_key, topic):
    if (openai_api_key == ""):
        raise gr.Error("OpenAI API Key is required.")
    if (serper_api_key == ""):
        raise gr.Error("Serper API Key is required.")
    if (topic == ""):
        raise gr.Error("Topic is required.")
    os.environ["OPENAI_API_KEY"] = openai_api_key
    os.environ["SERPER_API_KEY"] = serper_api_key
    #OPENAI_API_KEY = openai_api_key
    AGENTOPS_API_KEY = os.environ["AGENTOPS_API_KEY"]
    #logging.basicConfig(level=logging.DEBUG)
    
    #openai = OpenAI(api_key=OPENAI_API_KEY)
    
    agentops.init(AGENTOPS_API_KEY)
    return get_crew(model).kickoff(inputs={"topic": topic})
gr.close_all()
demo = gr.Interface(fn = invoke, 
                    inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
                              gr.Textbox(label = "Serper API Key", type = "password", lines = 1),
                              gr.Textbox(label = "Topic", value="Evolution of Retrieval-Augmented Generation from Naive RAG to Advanced RAG to Agentic RAG", lines = 1)],
                    outputs = [gr.Textbox(label = "Output", lines = 1)],
                    title = "Agentic RAG: LinkedIn Post Generation",
                    description = os.environ["DESCRIPTION"])
demo.launch() | 
