by moonboy

AI travel planner

Test this app for free
82
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):
Get full code

AI travel planner

Created: | Last Updated:

The app let's users submit travel prompts like weekend getaway in wales through a web interface and then shows them the location and the travel distances on a map. It uses GPT 4o to generate suggestions for spots and then find the coordinates for them and uses openrouter to find distances and commute times between the spots.

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:

  1. Open the Web Interface: Navigate to the provided URL to access the AI Travel Planner interface.
  2. Submit a Travel Prompt:
  3. Enter your travel prompt in the text area provided. For example, "I'm going to the Scottish Highlands for the weekend..."
  4. Click the Generate New Plan button to submit your prompt.
  5. Modify an Existing Plan:
  6. 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:

  1. 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.
  2. 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:
  3. 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.

Technologies

Flask Flask
AWS AWS
Python Python