Fetch temperature of a location along with tool integration

The pipeline demonstrates the functionality of OpenAI Assistant's tool-calling capabilities to fetch weather information and also obtain the list of tools used, which can be further fed into the model.

You need to set up an assistant in the OpenAI Dasboard. Below is an example of a JSON function definition that you must use in the Assistant to define the function:

          {
          "name": "get_weather",
          "description": "Determine weather in my location",
          "strict": true,
          "parameters": {
            "type": "object",
            "properties": {
             "city": {
              "type": "string",
              "description": "The city and state e.g. San Francisco, CA"
             }
            },
            "additionalProperties": false,
            "required": [
             "city"
            ]
           }
          }
        
  1. Configure the Create and Run Thread Snap with the Assistant ID and Prompt fields to obtain Maldives' temperature.
    Important: Ensure that you configure the Assistant ID in the Snap to match the one you created for the pipeline to run successfully.

    Create and Run Thread Snap configuration

  2. Configure the OpenAI Assistants Tool Call Router Snap to send an empty array of tools list in the first output view to the downstream Snaps to enable the tool collection in the downstream Message Appender.

    OpenAI Assistants Tool Call Router output preview

  3. Configure the HTTP Client Snap with the URI for the Weather API and the Query parameters, where q denotes the query for the location, and the key stands for the API key. They can be configured as follows:
    Tip: You must obtain your own API key from https://www.weatherapi.com/ by signing up for a free account.

    HTTP Client Snap configuration

  4. Configure the OpenAI Function Result Generator Snap to consolidate the results of the tool calls and return the weather information for the specified city.
    OpenAI Function Result Generator configuration OpenAI Function Result Generator output

    OpenAI Function Result Generator configuration


    OpenAI Function Result Generator output

  5. Configure the Message Appender Snap to append the messages from the tool results from tool call router and function result generator into one unified output.
    Message Appender configuration Message Appender output

    Message Appender Snap configuration


    Message Appender Snap output

  6. Configure the OpenAI Assistants Submit Tool Outputs Snap to submit the tool execution results to the Assistant and retrieve either the final response or the next tool-calling request.
    OpenAI Assistants Submit Tool Outputs configuration OpenAI Assistants Submit Tool Outputs output

    OpenAI Assistants Submit Tool Outputs Snap configuration


    OpenAI Assistants Submit Tool Outputs Snap output

To successfully reuse pipelines:
  1. Download and import the pipeline in to the SnapLogic Platform.
  2. Configure Snap accounts, as applicable.
  3. Provide pipeline parameters, as applicable.