Skip to content

About

A cognitive agent architecture using LangGraph and Python custom orchestration for adaptive travel planning. Employs a non-destructive state machine with dynamic self-evaluation, conditional re-search loops to fix data gaps, and robust Streamlit UI persistence guards alongside token-optimized data serialization.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โœˆ๏ธ Reflective Travel Assistant

A memory-aware agentic travel planning system built on LangGraph โ€” combining real-time weather data, web search, LLM reasoning, self-evaluation, and conditional re-search to generate personalized, visually enriched travel itineraries.


๐Ÿ“ธ Demo

Main Interface & Traveler Preferences

Dashboard Screenshot

Main Streamlit dashboard โ€” destination input, traveler preference sidebar, and the Generate Travel Plan trigger.


AI Travel Guide Output

Travel Guide Screenshot

Generated itinerary with live weather metrics, traveler profile cards, and the full personalized day-by-day plan.


Top Attractions Gallery

Attractions Screenshot

Curated sightseeing locations enriched with real images from the Pexels API.


Must-Try Foods Gallery

Foods Screenshot

Local culinary recommendations with images and descriptions, filtered by diet preference.


Agent Insights โ€” Reflection Trace

Agent Insights Screenshot

Live state machine execution log โ€” reflection cycles, confidence scores, identified gaps, and research sources.


๐ŸŽฌ Demo Video

Watch Demo Video

Click the thumbnail above to watch a full walkthrough of the agentic workflow.


๐Ÿ—๏ธ Architecture

Architecture Diagram

System architecture โ€” LangGraph StateGraph workflow with conditional reflection loop, external tool integrations, and Streamlit presentation layer.

High-Level Workflow

User Input (Destination + Preferences)
            โ”‚
            โ–ผ
   [LangGraph StateGraph]
            โ”‚
            โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚  Initial Collection โ”‚
  โ”‚  โ”œโ”€ WeatherAPI      โ”‚  โ† Current temperature, humidity, wind, condition
  โ”‚  โ””โ”€ Tavily Search   โ”‚  โ† Attractions, local foods, travel tips
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
             โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚   Reflection    โ”‚  โ† LLM evaluates information completeness
    โ”‚   Engine        โ”‚    Scores confidence (0โ€“100%)
    โ”‚                 โ”‚    Identifies specific knowledge gaps
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚                โ”‚
  SUFFICIENT      INSUFFICIENT (cycle < 2)
     โ”‚                โ”‚
     โ”‚                โ–ผ
     โ”‚     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚     โ”‚   Query Generator   โ”‚  โ† LLM generates targeted search queries
     โ”‚     โ”‚   + Researcher      โ”‚  โ† Tavily fills identified gaps
     โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚                โ”‚
     โ”‚                โ””โ”€โ”€โ”€โ”€ loops back to Reflection
     โ”‚
     โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚   Image Enrichment   โ”‚  โ† Pexels API attaches photos to attractions & foods
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
             โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚  Response Generation โ”‚  โ† LLM synthesizes personalized Markdown travel guide
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
             โ–ผ
   Streamlit Presentation Layer
   โ”œโ”€โ”€ Weather Dashboard
   โ”œโ”€โ”€ Traveler Profile Cards
   โ”œโ”€โ”€ AI Travel Guide (downloadable)
   โ”œโ”€โ”€ Attractions Gallery
   โ”œโ”€โ”€ Foods Gallery
   โ””โ”€โ”€ Agent Insights (reflection history + execution log + sources)

โœจ Features

  • Reflective agentic loop โ€” the agent evaluates its own information quality before generating a response; if gaps are found, it re-searches automatically
  • Confidence scoring โ€” every reflection cycle produces a 0โ€“100% confidence score derived from identified knowledge gaps, displayed as a live badge in the UI
  • Reflection history timeline โ€” each cycle's status, confidence, and specific gaps are logged and surfaced in the Agent Insights tab as collapsible expanders
  • Memory-aware personalization โ€” diet, travel style, budget, and transport preferences are stored in session memory and enforced at the prompt level
  • Multi-tool data collection โ€” WeatherAPI for real-time conditions, Tavily Search for discovery and re-research, Pexels API for visual enrichment
  • Deduplicated research merging โ€” research items from multiple cycles are deduplicated before being passed to the LLM, preventing repeated facts
  • Clean prompt construction โ€” only text-relevant fields (name, description) from travel data are sent to the LLM; image URLs and metadata are stripped to reduce token noise
  • Downloadable itinerary โ€” generated Markdown guide can be saved locally with one click
  • Session state persistence โ€” results survive sidebar interactions without re-running the agent
  • Research source transparency โ€” all Tavily sources used across research cycles are listed in the Agent Insights tab

โš™๏ธ Tech Stack

Component Technology
Frontend Streamlit
Workflow Orchestration LangGraph (StateGraph)
Agent Framework LangChain
Primary LLM Gemini Flash Lite
Secondary LLM Groq (LLaMA Models)
Weather Data WeatherAPI
Web Search & Research Tavily Search API
Image Retrieval Pexels API
Language Python 3.10+
Environment Python Virtual Environment

๐Ÿ“ Project Structure

reflective_travel_assistant/
โ”‚
โ”œโ”€โ”€ streamlit_app.py           # Streamlit dashboard โ€” UI, session state, result rendering
โ”œโ”€โ”€ main.py                    # CLI entry point
โ”œโ”€โ”€ env                        # Environment variables (API keys)
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”‚
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ langgraph_workflow.py  # LangGraph StateGraph โ€” nodes, edges, conditional router
โ”‚   โ””โ”€โ”€ response_generator.py # LLM prompt builder and final guide generator
โ”‚
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ weather_tool.py        # WeatherAPI integration โ€” temperature, humidity, wind
โ”‚   โ”œโ”€โ”€ discovery_tool.py      # Tavily-powered destination discovery
โ”‚   โ””โ”€โ”€ image_tool.py          # Pexels API image enrichment for attractions & foods
โ”‚
โ”œโ”€โ”€ reflection/
โ”‚   โ””โ”€โ”€ reflector.py           # LLM-based information evaluator โ€” status + gap detection
โ”‚
โ”œโ”€โ”€ research/
โ”‚   โ”œโ”€โ”€ query_generator.py     # LLM generates targeted queries for identified gaps
โ”‚   โ””โ”€โ”€ researcher.py          # Executes Tavily searches for additional information
โ”‚
โ”œโ”€โ”€ memory/
โ”‚   โ””โ”€โ”€ session_memory.py      # In-session traveler preference store
โ”‚
โ”œโ”€โ”€ llms/
โ”‚   โ””โ”€โ”€ router.py              # LLM provider selector
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ parser.py              # LLM response text extractor
โ”‚
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ styles.css             # Custom Streamlit CSS
โ”‚   โ”œโ”€โ”€ architecture.png       # System architecture diagram
โ”‚   โ””โ”€โ”€ screenshots/           # README screenshots
โ”‚
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

1. Clone the repository

git clone https://github.com/your-username/reflective-travel-assistant.git
cd reflective-travel-assistant

2. Create and activate a virtual environment

python -m venv venv

# Windows
venv\Scripts\activate

# macOS / Linux
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Set up environment variables

Create a file named env in the project root and add your API keys:

GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
WEATHER_API_KEY=your_weatherapi_key_here
PEXELS_API_KEY=your_pexels_api_key_here

5. Run the Streamlit app

streamlit run streamlit_app.py

Open http://localhost:8501 in your browser.


๐Ÿ”‘ Getting API Keys

Service Free Tier Link
Gemini Yes (generous limits) aistudio.google.com
Groq Yes (fast inference) console.groq.com
Tavily Yes (1,000 searches/month) tavily.com
WeatherAPI Yes (1M calls/month) weatherapi.com
Pexels Yes (unlimited, rate-limited) pexels.com/api

๐Ÿ”„ How the Reflection Loop Works

This is the core distinguishing feature of the system. Unlike a standard single-pass assistant:

  1. Initial collection โ€” weather and destination data are fetched in parallel via tool calls.
  2. Reflection โ€” the LLM reads all collected data and answers: "Is this enough to generate a complete, personalized travel guide?" It produces a SUFFICIENT or INSUFFICIENT verdict along with a list of specific missing topics (e.g., transportation options, seasonal events, winter packing advice).
  3. Conditional branch โ€” if INSUFFICIENT and the cycle count is below the limit, the agent generates targeted search queries for exactly the missing topics and re-searches.
  4. Cycle cap โ€” the loop runs at most 2 reflection cycles to prevent runaway API consumption. If the cap is hit, the agent proceeds with whatever it has and notes this in the execution log.
  5. Confidence score โ€” each cycle emits a 0โ€“100% confidence score (1.0 โˆ’ gaps ร— 0.2) so the UI can signal data quality to the user.

This means the final guide is always grounded in verified, sufficiently complete data โ€” not a best-guess single-pass output.


๐Ÿ“Š Agent Insights Tab

The Agent Insights tab exposes the full internal execution trace, making the system auditable rather than a black box:

Section What it shows
Reflection History Every cycle's verdict, confidence %, and specific gaps found โ€” as collapsible expanders
Execution Log Chronological step-by-step log of every node that ran
Research Sources All Tavily source URLs gathered across re-search cycles

๐Ÿ“„ Sample Output Sections

The generated Markdown travel guide includes:

  • Traveler Profile โ€” recap of all active preferences
  • Destination Overview โ€” culturally grounded introduction
  • Current Weather & Packing Tips โ€” conditions + practical clothing advice
  • Top Attractions โ€” grounded in discovered data, not invented
  • Must-Try Local Foods โ€” filtered by diet preference where applicable
  • Transportation Advice โ€” tailored to the selected transport preference
  • Seasonal Highlights โ€” month-specific events and conditions
  • Suggested Itinerary โ€” realistic day-by-day plan scaled to trip duration
  • Travel Tips & Warnings โ€” safety, customs, health, and scam awareness

๐Ÿ”ฎ Planned Enhancements

  • Persistent long-term memory (ChromaDB) for cross-session preference recall
  • Hotel and restaurant recommendation sub-agents
  • Budget estimation tool with cost breakdowns per day
  • Interactive map integration (Folium / Google Maps embed)
  • PDF itinerary export with images
  • Multi-agent architecture โ€” separate researcher, critic, and formatter agents
  • Structured tracing with Langfuse or OpenTelemetry

๐ŸŽฏ What This Project Demonstrates

  • LangGraph StateGraph design โ€” typed state, annotated reducers, conditional edges, and loop-back patterns
  • Reflective agentic reasoning โ€” self-evaluation and conditional re-search from first principles
  • Multi-tool orchestration โ€” three independent external APIs coordinated within a single graph
  • Memory-aware personalization โ€” session state driving prompt-level behavior, not just UI display
  • Production-grade prompt engineering โ€” separated prompt builder, text-only serialization of structured data, and explicit personalization rules
  • Modular Python architecture โ€” each concern (reflection, research, images, LLMs) is an isolated module with a single responsibility
  • Transparent AI systems โ€” full execution trace and confidence scoring surfaced to the end user

๐Ÿ“œ License

This project is intended for educational and portfolio purposes.

About

A cognitive agent architecture using LangGraph and Python custom orchestration for adaptive travel planning. Employs a non-destructive state machine with dynamic self-evaluation, conditional re-search loops to fix data gaps, and robust Streamlit UI persistence guards alongside token-optimized data serialization.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages