from crewai import Agent, Task, Crew, Process from crewai_tools import SerperDevTool import gradio as gr import os os.environ["OPENAI_API_KEY"] =os.getenv("API_Key") os.environ["OPENAI_API_BASE"] = 'https://api.groq.com/openai/v1' os.environ["OPENAI_MODEL_NAME"] ='llama3-70b-8192' def main(): with gr.Blocks() as demo: with gr.Row(): with gr.Column(scale=3): text_input = gr.Textbox(lines=4, placeholder="Please type in the city name you want to explore") with gr.Row(): with gr.Column(scale=1): text_output = gr.Textbox(lines=4, placeholder="Here is the brief about the city") with gr.Row(): text_button = gr.Button("Send") text_button.click(agent, text_input, text_output) demo.launch() def agent(text_input): city=text_input responder = Agent( role='Local Expert at this city', goal='Provide the BEST insights about the selected city', backstory="""A knowledgeable local guide with extensive informationabout the city, it's attractions and customs""", verbose=True, allow_delegation = False,) respond = Task( description = f"As a local expert on this '{city}' you must compile an in-depth guide for someone traveling there and wanting to have THE BEST trip ever! Gather information about key attractions, local customs, special events, and daily activity recommendations. Find the best spots to go to, the kind of place only a local would know. This guide should provide a thorough overview of what the city has to offer, including hidden gems, cultural hotspots, must-visit landmarks, weather forecasts, and high level costs.", agent = responder, expected_output = f"The final answer must be a comprehensive '{city}' guide, rich in cultural insights and practical tips, tailored to enhance the travel experience.",) crew = Crew(agents = [responder],tasks = [respond],verbose = 2,process = Process.sequential) output = crew.kickoff() return output if __name__ == "__main__": main()