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.
-
Configure the JSON Generator Snaps (`Request1` and `Request2`) to generate JSON input data for the city names.
-
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." -
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."
-
In the Request1 Snap, configure the JSON data to represent a city. The input data should look like this for
-
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.
-
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
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. -
Configure the OpenAI Tool Calling Snap to call the tools in parallel, sending requests for both weather and Wikipedia info simultaneously.
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. -
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.
-
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.
-
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.
-
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.
-
Configure the Mapper Snap to map the final output with the appended weather and wiki information.
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.
- Download and import the pipeline into SnapLogic Platform.
- Configure Snap accounts, as applicable.
- Provide pipeline parameters, as applicable.