by moonboy
AI travel planner
import logging
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app
# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
def load(self):
Created: | Last Updated:
Introduction to the AI Travel Planner Template
The AI Travel Planner template allows users to submit travel prompts, such as "weekend getaway in Wales," through a web interface. The app then generates a travel plan, displaying locations and travel distances on a map. This guide will walk you through the steps to set up and use the AI Travel Planner template.
Getting Started
To get started with the AI Travel Planner template, click Start with this Template.
Test
After starting with the template, press the Test button. This will begin the deployment of the app and launch the Lazy CLI. Follow any prompts that appear in the CLI to complete the setup.
Entering Input
Once the app is deployed, you can interact with it through the web interface. Here’s how to use the app:
- Open the Web Interface: Navigate to the provided URL to access the AI Travel Planner interface.
- Submit a Travel Prompt:
- Enter your travel prompt in the text area provided. For example, "I'm going to the Scottish Highlands for the weekend..."
- Click the Generate New Plan button to submit your prompt.
- Modify an Existing Plan:
- If you have an existing plan and want to modify it, enter your new prompt and click the Modify this Plan button.
Using the App
The AI Travel Planner interface includes several features:
- Mobile and Desktop Headers: The app adapts to both mobile and desktop views, displaying appropriate navigation menus.
- Travel Plan Display: After submitting a prompt, the app will display a travel plan broken down by days, including activities and locations.
- View Plan on Map: Click the View Plan on Map button to see the travel plan on a map. The map will show the locations and travel routes for each day of your trip.
Integrating the App
If you need to integrate the app with external services, follow these steps:
- Get Coordinates for Locations: The app uses the Nominatim geocoding service to get coordinates for each location. Ensure you have an internet connection to access this service.
- Calculate Travel Info: The app uses the OpenRouteService API to calculate travel time and distance between locations. You will need an API key from OpenRouteService. Set this key in the Environment Secrets tab within the Lazy Builder:
- OPENROUTESERVICE_API_KEY: Obtain this key from the OpenRouteService website and add it to your environment secrets.
Sample Code for External Integration
If you need to integrate the app's API into another service, here is a sample request and response:
Sample Request
```json POST /submit_prompt Content-Type: application/json
{ "prompt": "I'm going to the Scottish Highlands for the weekend..." } ```
Sample Response
json
{
"plan": {
"days": [
{
"day": 1,
"locations": [
{
"name": "Location Name",
"description": "Brief description of the activity or place",
"country": "Country Name",
"state": "State or County Name",
"city": "City Name",
"coordinates": [latitude, longitude],
"travel_to_next": {
"duration": "X hours",
"distance": "Y km"
}
}
]
}
]
}
}
By following these steps, you can successfully set up and use the AI Travel Planner template to generate and view travel plans based on user prompts.