Skip to content

ashumishra2104/AI_Travel_agent_Streamlit

Repository files navigation

πŸš€ Streamlit Travel Agent Setup Guide

πŸ“ Project Structure (Updated)

ai-travel-agent/
β”œβ”€β”€ app.py                    # πŸ†• Main Streamlit application
β”œβ”€β”€ Assignment.ipynb          # Original Jupyter notebook  
β”œβ”€β”€ README.md                 # Project documentation
β”œβ”€β”€ requirements.txt          # πŸ”„ Updated dependencies (includes Streamlit)
β”œβ”€β”€ .env                     # Environment variables (keep local)
β”œβ”€β”€ .gitignore               # Git ignore file
└── .streamlit/              # πŸ†• Streamlit configuration (optional)
    └── config.toml          # Custom Streamlit settings

πŸ”§ Setup Instructions

1. Create the Streamlit App File

Create app.py in your project folder and copy the code from the artifact above.

2. Update Requirements

Replace your requirements.txt with the updated version that includes Streamlit.

3. Verify Your .env File

Make sure your .env file contains:

OPENAI_API_KEY=your_openai_api_key_here
SERPER_API_KEY=your_serper_api_key_here  
OPENWEATHERMAP_API_KEY=your_openweathermap_api_key_here

4. Install Dependencies

pip install -r requirements.txt

πŸš€ Running Locally

Method 1: Simple Run

streamlit run app.py

Method 2: Custom Port

streamlit run app.py --server.port 8080

Method 3: Development Mode

streamlit run app.py --server.runOnSave true

Your app will open automatically in your browser at http://localhost:8501

🌐 Deployment Options

Option 1: Streamlit Community Cloud (FREE & RECOMMENDED)

  1. Push to GitHub (make sure your code is on GitHub)
  2. Go to share.streamlit.io
  3. Connect your GitHub account
  4. Deploy your repository:
    • Repository: your-username/ai-travel-agent
    • Branch: main
    • Main file path: app.py
  5. Add secrets in Streamlit Cloud dashboard:
    • Go to "Manage app" β†’ "Secrets"
    • Add your API keys:
    OPENAI_API_KEY = "your_key_here"
    SERPER_API_KEY = "your_key_here"  
    OPENWEATHERMAP_API_KEY = "your_key_here"

Your app will be live at: https://your-app-name.streamlit.app

Option 2: Heroku

  1. Create Procfile:
web: sh setup.sh && streamlit run app.py --server.port=$PORT --server.address=0.0.0.0
  1. Create setup.sh:
mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml
  1. Deploy to Heroku:
heroku create your-travel-agent-app
git push heroku main
heroku config:set OPENAI_API_KEY=your_key_here
heroku config:set SERPER_API_KEY=your_key_here
heroku config:set OPENWEATHERMAP_API_KEY=your_key_here

Option 3: Railway

  1. Connect your GitHub repository
  2. Add environment variables in Railway dashboard
  3. Deploy automatically

🎨 Optional: Custom Streamlit Configuration

Create .streamlit/config.toml:

[theme]
primaryColor = "#667eea"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#f0f2f6"
textColor = "#262730"

[server]
runOnSave = true

πŸ§ͺ Testing Your App

Test Locally:

  1. Run streamlit run app.py
  2. Try different example queries
  3. Verify all tools are working

Test Features:

  • βœ… Weather information displays
  • βœ… Search results appear
  • βœ… Calculations work correctly
  • βœ… YouTube videos load
  • βœ… Currency conversion functions
  • βœ… Cost breakdown is accurate

πŸ“± Mobile Responsiveness

Your Streamlit app is automatically mobile-responsive! Users can access it on:

  • πŸ’» Desktop computers
  • πŸ“± Mobile phones
  • πŸ“Ÿ Tablets

πŸ”’ Security Best Practices

For Production:

  1. Never commit API keys to GitHub
  2. Use Streamlit Secrets for deployment
  3. Add rate limiting if needed
  4. Monitor API usage to avoid overages

Environment Variables:

# In app.py - already handled
import os
from dotenv import load_dotenv
load_dotenv()

# API keys loaded securely
openai_key = os.getenv("OPENAI_API_KEY")

πŸ› Troubleshooting

Common Issues:

"ModuleNotFoundError"

pip install -r requirements.txt

"API Key Error"

  • Check your .env file
  • Verify API keys are correct
  • Ensure no extra spaces in API keys

"Streamlit Command Not Found"

pip install streamlit

"Port Already in Use"

streamlit run app.py --server.port 8502

πŸ“ˆ Performance Tips

  1. Cache API calls using @st.cache_data
  2. Use session state for expensive operations
  3. Optimize large responses with pagination
  4. Add loading indicators for better UX

🎯 Next Steps

  1. βœ… Create the Streamlit app
  2. βœ… Test locally
  3. βœ… Deploy to Streamlit Cloud
  4. βœ… Share your live app link!

🌟 Features in Your Streamlit App

  • 🎨 Beautiful UI with custom styling
  • πŸ“± Mobile responsive design
  • πŸ”„ Real-time processing with loading indicators
  • πŸ“Š Interactive components (selectboxes, buttons, metrics)
  • πŸ’Ύ Session state for chat history
  • 🎯 Example queries for easy testing
  • πŸ“ˆ API status monitoring
  • πŸŽ₯ Embedded YouTube videos

Your travel agent is now a full-featured web application! πŸŽ‰

Live Demo: https://your-app-name.streamlit.app (after deployment)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages