OpenAI Tool Calling

Overview

You can use this snap to provide external tools for the model to call, supplying internal data and information for the model's responses.


OpenAI Tool Calling

Prerequisites

None.

Limitations and known issues

None.

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has one document input view, typically carrying the input message for the OpenAI model.
Output This Snap has exactly two document output views. The first one outputs the full response from the model. The second one outputs the list of tools to call. It includes a JSON argument, whose value is a JSON object derived from converting the string-formatted argument of the model's response tool call.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when the Snap encounters an error.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Note:
  • Suggestion icon (): Indicates a list that is dynamically populated based on the configuration.
  • Expression icon (): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.
  • Add icon (Plus Icon): Indicates that you can add fields in the field set.
  • Remove icon (Minus Icon): Indicates that you can remove fields from the field set.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: OpenAI Tool Calling

Example: Invoke gpt-4 model for sentiment analysis

Model name String/Expression/Suggestion Required. Specify the name of the OpenAI model you want to use, such as gpt-4o or gpt-4o-mini.

Default value: N/A

Example: gpt-4o

Message payload String/Expression Required. Enter the message payload that will be processed by the model. This payload typically includes input messages in JSON format. The message is an array passed from the input document and obtained through an expression.

Default value: N/A

Example: $inputMessage

Tool payload String/Expression Required. Enter the tool payload that defines the tools (name, description, parameters, etc.) the model can choose to call.
Note: The model cannot directly call tools. It can only suggest, based on the tool definition, which tools are required to respond to the user's original prompt. The actual tool invocation is the user's responsibility.

Default value: N/A

Example: $specifiedTools

Advanced tool configuration Use this field set to allow users to enable fine-tuned control over how the tool operates within the pipeline. Each field within this set provides specific customization options to optimize the performance and results.
Tool choice Dropdown list/Expression Required.
Choose the tool or function you want to call within the model. Options available are:
  • SPECIFY A FUNCTION: Forces the model to call that tool.
  • REQUIRED: The model must call one or more tools.
  • NONE: The model doesn't call any tool and instead generates a message.
  • AUTO: The model can pick between generating a message or calling one or more tools.
Note: If you select either REQUIRED or SPECIFY A FUNCTION (i.e. force the model to call a function) then the subsequent finish_reason will be stop instead of being tool_calls.

Default value: AUTO

Example: REQUIRED

Function name String/Expression Required.

Appears when SPECIFY A FUNCTION is selected in Tool choice is expression-enabled.

Provide the function name that you want to call from the model. This field is required when specifying a function.

Default value: None

Example: Analyze sentiment

Parallel tool call Checkbox/Expression

Select this checkbox to enable parallel calls to multiple tools.

Default status: Selected

Model parameters Configure the parameters to tune the model runtime.
Maximum tokens Integer/Expression

Specify the maximum number of tokens to generate in the chat completion. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 50

Temperature Decimal/Expression

Specify the sampling temperature to use a decimal value between 0 and 1. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 0.2

Top P Decimal/Expression

Specify the nucleus sampling value, a decimal value between 0 and 1. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 0.2

Stop sequences String/Expression

Specify a sequence of texts or tokens to stop the model from generating further output. Learn more.

Note:
  • You can configure up to four stop sequences when generating the text. These stop sequences tell the model to halt further text generation if any of the specified sequences are encountered.
  • The returned text does not contain the stop sequence.

Default value: N/A

Example: pay, ["amazing"], ["September", "paycheck"]
Advanced prompt configuration Configure the prompt settings to guide the model responses and optimize output processing.
JSON modeCheckbox/Expression Select this checkbox to enable the model to generate strings that can be parsed into valid JSON objects. The output includes the json_output field that contains the parsed JSON object, encapsulating the data.
Snap execution Dropdown list Select one of the three modes in which the Snap executes.
Available options are:
  • Validate & Execute. Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only. Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled. Disables the Snap and all Snaps that are downstream from it.

Troubleshooting

Failure: Tool payload property is missing

No tool payload was provided in the Snap configuration.

Specify a valid tool payload and try again

Failure: Tool payload must be a list.

The tool payload is not configured as a list

Verify that the tool payload is a list and try again.

Failure: Function name is required when specifying a function.

The function name was not provided when using a specified function

Specify a valid function name and try again.

Failure: Empty choices list.

The choices list provided in the configuration is empty

Verify the choices list and ensure it is not empty.

Failure: Invalid configuration to execute tool calling.

The tool payload is empty or has an incorrect type

Verify that the tool payload is a non-empty list of valid tool objects.

Examples