This project implements a Flask web application that acts as a travel guide bot, leveraging Google's Gemini AI model for generating responses and OpenAI's image generation API for creating images.
- AI-powered travel planning: The bot provides personalized travel plans based on user prompts, considering weather conditions and suggesting relevant activities.
- Weather information: The bot fetches weather data for the location mentioned in the prompt using the OpenWeatherMap API.
- Image generation: The bot generates images based on user prompts using OpenAI's image generation API.
- Conversation context: The bot maintains conversation context, remembering previous responses and using them to provide more relevant and personalized suggestions.
-
Create a
.env
file:- Create a file named
.env
in the project root directory. - Add the following lines, replacing the placeholders with your actual API keys:
GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY OPENAI_API_KEY=YOUR_OPENAI_API_KEY
- You can obtain your API keys from the Google Cloud Platform and OpenAI websites.
- Create a file named
-
Install dependencies:
- Install the required Python packages using pip:
pip install -r requirements.txt
- Install the required Python packages using pip:
- Start the Flask server:
- Run the following command in your terminal:
flask run
- The application will be accessible at
http://127.0.0.1:5000/
.
- Run the following command in your terminal:
- Access the web application: Open the URL
http://127.0.0.1:5000/
in your web browser. - Enter a prompt: Type your travel-related prompt in the text area and click the "SUBMIT" button.
- View the response: The bot will generate a response based on your prompt, including weather information and travel suggestions.
- Generate an image: Enter a description for the image you want to generate in the "Visualize Your Destination" section and click the "Generate Image" button.
The project consists of the following files:
app.py
: The main Flask application file, containing the routes, API calls, and logic for the bot.templates/index.html
: The HTML template for the frontend interface.static/
: Folder containing static files like CSS and JavaScript.
- Flask
- google.generativeai
- pyttsx3
- requests
- openai
- dotenv
- os
- This project requires an active Google Cloud Platform account and an OpenAI API key.
- The
gemini-1.5-flash
model is used for generating responses. You can explore other Gemini models available on Google Cloud. - The OpenWeatherMap API key is hardcoded in the
get_weather
function. You can replace it with your own API key. - The
clean_text
function removes asterisk characters from the response, which might be used for formatting purposes. - The
session
dictionary stores conversation context, allowing the bot to remember previous responses.
- Error handling: Implement more robust error handling for API calls and other potential issues.
- User authentication: Add user authentication to personalize travel plans and store user preferences.
- Database integration: Store conversation history and user data in a database for persistence.
- More advanced features: Explore additional features like trip itinerary generation, booking functionality, and integration with other travel-related APIs.