Function Generator

Overview

Use this Snap to generate a tool definition.


Function Generator Snap dialog

  • Format-type Snap

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has one document input view.
Output This Snap has one document output view. The output is a tool definition structured according to SnapLogic's internal schema. It can be seamlessly consumed in a Tool Calling Snap as one element in the tool payload.
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 an error occurs.
  • 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

Legend:
  • Expression icon (): Allows using JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
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: Function Generator

Example: toolCaller

Name String/Expression

Required. Specify the tool name, and the model calls that specific tool with the same name.

Important: Following are the supported characters for the function name: lowercase (a-z), uppercase (A-Z), numbers (0-9), underscores (_), and dashes (-).
Minimum value: 1 character

Maximum value: 64 characters

Default value: N/A

Example: weather_tool

Description String/Expression

A description of what the function does.

Default value: N/A

Example: weather_tool
Strict Mode Checkbox

For OpenAI LLMs only Select this checkbox to ensure that the Snap validates the input parameters strictly according to the defined schema or constraints. When enabled, the model will follow the exact schema defined in the Parameters field.

Default status: Deselected

Note: The Snap supports only a subset of JSON Schema when this checkbox is selected. A list of unsupported JSON schema can be found. here. If the checkbox is selected, all fields much be required. Otherwise, OpenAI will respond with an error,
Input Mode Dropdown list

The mode in which the function generator operates.

  • JSON Schema Mode
  • Express Mode

Default value: Express Mode

Example: Express Mode

Parameters String/Expression

Appears Express Mode is selected.

The parameters the function accepts.

Default value: Example:
JSON Schema Button

Appears when JSON Schema Mode is selected.

JSON Schema for the function definition. Click the JSON Schema button to open the JSON Editor

Default value: Default JSON Schema editor contents:


JSON Schema default contents

Tool path String/Expression

The pipeline that will be executed when this tool is called.

Default value: N/A

Example: weather_tool_pipe
Custom metadata The metadata associated with the function definitions. This metadata is user-defined and can be used in subsequent Snaps, such as the Pipeline Execute Snap, to enable more flexible and contextual execution.

These metadata key-value pairs appear under the sl_tool_metadata in the output format. Neither system nor customer metadata are sent to the LLM.

Key String/Expression Specify the key to use for the metadata. If the metadata key is empty, the Snap displays an error.

Default value: N/A

Example: key1

Value String/Expression Specify the value to use for the metadata. If the metadata value is empty, no error is displayed, however, appears as null in the output.

Default value: N/A

Example: value1

Snap execution Dropdown list
Choose 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.

Default value: Validate & Execute

Example: Execute only

Custom metadata example

For all Function Generator Snaps, you can define metadata for your tool definitions. The following screenshot provides an example of how the Snap output displays the metadata.