Overview

The Tourist Plan task demonstrates how to:

  • Execute Julep workflow-steps in parallel
  • Integrate with external APIs (Weather and Brave Search)
  • Combine data from multiple sources
  • Generate personalized itineraries using AI

Task Structure

Let’s break down the task into its core components:

1. Input Schema

First, we define what inputs our task expects:


input_schema:
    type: object
    properties:
        locations:
            type: array
            items:
                type: string

This schema specifies that our task expects an array of location strings (e.g., ["New York", "London", "Paris"]).

2. Tools Configuration

Next, we define the external tools our task will use:

- name: weather
  type: integration
  integration:
    provider: weather
    setup:
      openweathermap_api_key: YOUR_OPENWEATHERMAP_API_KEY

- name: internet_search
  type: integration
  integration:
    provider: brave
    setup:
      api_key: YOUR_BRAVE_API_KEY

We’re using two integrations:

  • The weather integration to fetch current weather conditions
  • The brave search integration to find tourist attractions

3. Main Workflow Steps

1

Get Weather Data

- over: inputs[0].locations
  map:
    tool: weather
    arguments:
      location: _

This step:

  • Iterates over each location in the input array
  • Calls the weather API for each location
2

Search for Tourist Attractions

- over: inputs[0].locations
  map:
    tool: internet_search
    arguments:
      query: "'tourist attractions in ' + _"

This step:

  • Iterates over the locations again
  • Searches for tourist attractions in each location
  • Constructs a search query by concatenating “tourist attractions in ” with the location
3

Combine Data

- evaluate:
  zipped: |-
    list(
      zip(
        inputs[0].locations,
        [output['result'] for output in outputs[0]],
        outputs[1]
      )
    )

This step:

  • Combines the data from previous steps into tuples
  • Each tuple contains: (location, weather_data, attractions_data)
  • Uses Python’s zip function to align the data
4

Generate Itineraries

- over: _['zipped']
  parallelism: 3
  # Inside the map step, each `_` represents the current element in the list
  # which is a tuple of (location, weather, attractions)
  map:
    prompt:
    - role: system
      content: >-
        You are {{agent.name}}. Your task is to create a detailed itinerary
        for visiting tourist attractions in some locations.
        The user will give you the following information for each location:

        - The location
        - The current weather condition
        - The top tourist attractions
    - role: user
      content: >-
        Location: "{{_[0]}}"
        Weather: "{{_[1]}}"
        Attractions: "{{_[2]}}"
    unwrap: true

This step:

  • Processes up to 3 locations in parallel
  • For each location tuple:
    • Sends a prompt to the AI model
    • Includes location, weather, and attraction data
    • Generates a personalized itinerary
5

Format Final Output

- evaluate:
  final_plan: |-
    '\\n---------------\\n'.join(activity for activity in _)

This step:

  • Combines all itineraries into a single output
  • Separates each itinerary with a divider

Example Output

An example output when running this task with an input of ["New York", "London", "Paris", "Tokyo", "Sydney"]:

Next Steps

Try this task yourself, check out the full example, see the trip-planning cookbook.