3. Main Workflow Steps

1

Get Weather Data

- over: $ steps[0].input.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: $ steps[0].input.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(
          steps[0].input.locations,
          [output['result'] for output in steps[0].output],
          steps[1].output
        )
      )

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: >-
        $ f'''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: >-
        $ f'''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

Next Step