Parallel tool calling

This example pipeline demonstrates how to use OpenAI Tool Calling Snap to simultaneously fetch weather information and Wikipedia URLs by leveraging OpenAI Function Generator Snaps and API integrations.

  1. Configure the JSON Generator Snaps (`Request1` and `Request2`) to generate JSON input data for the city names.
    1. In the Request1 Snap, configure the JSON data to represent a city. The input data should look like this for Request1.
      This Snap generates a JSON document representing the city "San Francisco."
    2. In the Request2 Snap, configure the JSON data for another city. The input data should look like this for Request2.

      This Snap generates a JSON document representing the city "New York."

  2. Use a Union Snap to merge the inputs from Request1 and Request2 to create a unified data stream.
    The Union Snap combines the outputs from both Request1 and Request2.
  3. Configure the OpenAI Function Generator Snaps (`get_weather` and `get_wiki`) to generate function requests for weather information and Wikipedia URLs based on the input city.
    OpenAI Function Generator configuration OpenAI Function Generatoroutput

    Get Weather Snap configuration


    Get Weather Snap output


    Get Wiki Snap configuration


    Get Wiki Snap output

    This Snap generates the function definition for getting weather information. Since it expects city input, it will use the city names from the upstream Union Snap.
  4. Configure the OpenAI Tool Calling Snap to call the tools in parallel, sending requests for both weather and Wikipedia info simultaneously.

    OpenAI Tool Calling Snap configuration

    This Snap invokes both the weather and wiki functions using tool calling in parallel. The output contains the responses from the two functions for each city.
  5. Configure the Router Snaps (`weather api` and `wiki api`) to route or direct the flow of data based on specific conditions. It allows the pipeline to split the input data into different paths based on predefined conditions, ensuring that different sets of data are processed by the appropriate downstream Snaps.
    The Router Snap routes the tool call responses (from the weather API and Wiki API) to the respective pipelines.
  6. Configure the Pipeline Execute Snaps to call the weather API and wiki API pipelines. This Snap is used to execute the API calls from weather API and weather API for weather data and Wikipedia information.
    The weather api Snap gets the current weather for the city. The input is routed from Router1 and processes weather data.
    The wiki api Snap fetches Wikipedia URLs for the cities.
  7. Configure the OpenAI Function Result Generator Snaps to process the results of the tool calls and return the weather information and Wikipedia URL for the specified city.
    This Snap generates the final output for the tool calls.
  8. Configure the Message Appender Snap to append the messages from the tool results into one unified output.
    The Message Appender Snap appends the weather and Wikipedia data for each city into one message.
  9. Configure the Mapper Snap to map the final output with the appended weather and wiki information.
    Mapper Snap configuration Mapper Snap output

    Mapper Snap configuration


    Mapper Snap output

    Each Snap in the pipeline contributes to building the final message by calling the weather and Wikipedia APIs, processing the results, and appending them together for the two cities.
To successfully reuse pipelines:
  1. Download and import the pipeline into the SnapLogic Platform.
  2. Configure Snap accounts, as applicable.
  3. Provide pipeline parameters, as applicable.