A demonstration of the parallel agent architecture using Pydantic AI and LangGraph. This project implements a multi-agent travel planning system that helps users plan their perfect trip through an interactive Streamlit UI.
This project implements a sophisticated travel planning system that uses multiple specialized AI agents working in parallel to create comprehensive travel plans. The system collects user preferences and travel details through a conversational interface, then simultaneously processes flight, hotel, and activity recommendations before combining them into a final travel plan.
All tool calls for the agents are mocked, so this isn't using real data! This is simply built as an example, focusing on the agent architecture instead of the tooling.
- Interactive Streamlit UI with real-time streaming responses
- Multi-agent architecture with specialized agents for different aspects of travel planning
- Parallel processing of recommendations for improved efficiency
- User preference management for airlines, hotel amenities, and budget levels
- Conversational interface for gathering travel details
- Comprehensive travel plans with flights, accommodations, and activities
The system consists of five specialized agents:
- Info Gathering Agent: Collects necessary travel details (destination, origin, dates, budget)
- Flight Agent: Recommends flights based on travel details and user preferences
- Hotel Agent: Suggests accommodations based on destination, dates, budget, and amenity preferences
- Activity Agent: Recommends activities based on destination, dates, and weather forecasts
- Final Planner Agent: Aggregates all recommendations into a comprehensive travel plan
These agents are orchestrated through a LangGraph workflow that enables parallel execution and dynamic routing based on the completeness of gathered information.
- Pydantic AI: For structured agent definitions and type validation
- LangGraph: For orchestrating the agent workflow and parallel execution
- Streamlit: For building the interactive user interface
- Python 3.11 or higher
- OpenAI or OpenRouter API key (can use Ollama too)
-
Clone the repository:
git clone https://github.com/yourusername/travel-planning-agent.git cd travel-planning-agent
-
Set up a virtual environment:
Windows:
python -m venv venv venv\Scripts\activate
macOS/Linux:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and follow the instructions given in.env.example
:PROVIDER= BASE_URL= LLM_API_KEY= MODEL_CHOICE=
-
Start the Streamlit UI:
streamlit run streamlit_ui.py
-
Open your browser and navigate to the URL displayed in the terminal (typically http://localhost:8501)
-
Set Your Preferences: Use the sidebar to set your preferred airlines, hotel amenities, and budget level.
-
Start a Conversation: Type your travel request in the chat input. For example:
I want to go to Tokyo from Minneapolis. Jun 1st, returning on 6th. Max price for hotel is $300 per night.
-
Interact with the Agent: The system will ask follow-up questions if any details are missing.
-
Review Your Plan: Once all details are collected, the system will generate a comprehensive travel plan with flight, hotel, and activity recommendations.
Note that with this demonstration, once the final plan is given to you, the conversation is over. This can of course be extended to allow for editing the trip, asking more questions, etc.
RAGgle/
├── agents/ # Individual agent definitions
│ ├── activity_agent.py # Agent for recommending activities
│ ├── final_planner_agent.py # Agent for creating the final travel plan
│ ├── flight_agent.py # Agent for flight recommendations
│ ├── hotel_agent.py # Agent for hotel recommendations
│ └── info_gathering_agent.py # Agent for collecting travel details
├── agent_graph.py # LangGraph workflow definition
├── streamlit_ui.py # Streamlit user interface
├── utils.py # Utility functions
├── requirements.txt # Project dependencies
└── README.md # Project documentation
- The system starts by gathering all necessary information from the user through the Info Gathering Agent.
- Once all required details are collected, the system simultaneously calls the Flight, Hotel, and Activity agents to get recommendations.
- Each specialized agent uses its tools to search for and recommend options based on the user's preferences.
- After all recommendations are collected, the Final Planner Agent creates a comprehensive travel plan.
- The entire process is streamed in real-time to the user through the Streamlit UI.
This project is a demonstration of the parallelization workflow showcased in Anthropic's Agent Architecture blog. The implementation follows a similar pattern where multiple specialized agents work in parallel to solve different aspects of a complex task.
The key architectural pattern demonstrated here is the ability to:
- Gather initial information
- Fan out to multiple specialized agents working in parallel
- Aggregate results into a final, comprehensive response
This approach significantly improves efficiency compared to sequential processing, especially for complex tasks with independent subtasks.
You can customize the system by:
- Modifying agent prompts in the respective agent files
- Adding new specialized agents for additional travel aspects
- Enhancing the tools with real API integrations for flights, hotels, and activities
- Extending the user preference system with additional options
This project is licensed under the MIT License.
- Built with Pydantic AI
- Powered by LangGraph
- UI created with Streamlit