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
Create app.py in your project folder and copy the code from the artifact above.
Replace your requirements.txt with the updated version that includes Streamlit.
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_herepip install -r requirements.txtstreamlit run app.pystreamlit run app.py --server.port 8080streamlit run app.py --server.runOnSave trueYour app will open automatically in your browser at http://localhost:8501
- Push to GitHub (make sure your code is on GitHub)
- Go to share.streamlit.io
- Connect your GitHub account
- Deploy your repository:
- Repository:
your-username/ai-travel-agent - Branch:
main - Main file path:
app.py
- Repository:
- 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
- Create
Procfile:
web: sh setup.sh && streamlit run app.py --server.port=$PORT --server.address=0.0.0.0
- Create
setup.sh:
mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml- 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- Connect your GitHub repository
- Add environment variables in Railway dashboard
- Deploy automatically
Create .streamlit/config.toml:
[theme]
primaryColor = "#667eea"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#f0f2f6"
textColor = "#262730"
[server]
runOnSave = true- Run
streamlit run app.py - Try different example queries
- Verify all tools are working
- β Weather information displays
- β Search results appear
- β Calculations work correctly
- β YouTube videos load
- β Currency conversion functions
- β Cost breakdown is accurate
Your Streamlit app is automatically mobile-responsive! Users can access it on:
- π» Desktop computers
- π± Mobile phones
- π Tablets
- Never commit API keys to GitHub
- Use Streamlit Secrets for deployment
- Add rate limiting if needed
- Monitor API usage to avoid overages
# 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")"ModuleNotFoundError"
pip install -r requirements.txt"API Key Error"
- Check your
.envfile - 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- Cache API calls using
@st.cache_data - Use session state for expensive operations
- Optimize large responses with pagination
- Add loading indicators for better UX
- β Create the Streamlit app
- β Test locally
- β Deploy to Streamlit Cloud
- β Share your live app link!
- π¨ 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)