Skip to content
프로젝트

ashumishra2104/AI_Travel_agent_Streamlit

GitHub에서 보기

소개

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

기타 프로젝트

이 수치를 측정하는 방법

What you can do

  • ✅ Weather information displays
  • ✅ Search results appear
  • ✅ Calculations work correctly
  • ✅ YouTube videos load

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

🚀 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)

관련 프로젝트 살펴보기

불러오는 중…