Spaces:
Running
Running
import streamlit as st | |
from dotenv import load_dotenv | |
from crewai import Crew | |
from tasks import TripPlanTask | |
from agents import TripPlanAgents | |
# Load environment variables | |
load_dotenv() | |
# Streamlit frontend | |
st.title('Trip Planner') | |
city = st.text_input('Enter the city:') | |
month = st.text_input('Enter the month:') | |
if st.button('Plan Trip'): | |
if not city or not month: | |
st.error("Please enter both city and month") | |
else: | |
# Perform trip planning tasks | |
tasks = TripPlanTask() | |
agents = TripPlanAgents() | |
research_agent = agents.research_agent() | |
trip_planning_agent = agents.trip_planning_agent() | |
summary_and_plan_agent = agents.summary_and_plan_agent() | |
research_task = tasks.research_task(research_agent, city, month) | |
trip_planning_task = tasks.trip_planning_task(trip_planning_agent, city, month) | |
summary_and_plan_task = tasks.summary_and_plan(summary_and_plan_agent, city) | |
crew = Crew( | |
agents=[ | |
research_agent, | |
trip_planning_agent, | |
summary_and_plan_agent | |
], | |
tasks=[ | |
research_task, | |
trip_planning_task, | |
summary_and_plan_task | |
] | |
) | |
result = crew.kickoff() | |
# Display the results in a user-friendly format | |
if isinstance(result, dict): | |
st.write("Trip Plan Summary:") | |
for key, value in result.items(): | |
st.subheader(key) | |
st.write(value) | |
else: | |
st.write(result) | |