function_schema

Function schema utilities for AI tool definitions.

This module provides standardized function schema representation for defining tools and functions used with AI models, ensuring consistent formatting across different AI service providers.

class pipecat.adapters.schemas.function_schema.FunctionSchema(name: str, description: str, properties: dict[str, Any], required: list[str], handler: FunctionCallHandler | None = None)[source]

Bases: object

Standardized function schema representation for tool definition.

Provides a structured way to define function tools used with AI models like OpenAI. This schema defines the function’s name, description, parameter properties, and required parameters, following specifications required by AI service providers.

A schema may also carry the handler that runs when the function is called. When set, the LLM service registers it automatically for any LLMContext that advertises the schema, so no separate register_function call is needed.

__init__(name: str, description: str, properties: dict[str, Any], required: list[str], handler: FunctionCallHandler | None = None) None[source]

Initialize the function schema.

Parameters:
  • name – Name of the function to be called.

  • description – Description of what the function does.

  • properties – Dictionary defining parameter types, descriptions, and constraints.

  • required – List of property names that are required parameters.

  • handler – Optional handler for this function. When provided, the LLM service registers it automatically wherever the schema is advertised in the LLMContext, making a separate register_function call unnecessary. Decorate the handler with @tool_options to override its default call options (cancel_on_interruption, timeout_secs).

to_default_dict() dict[str, Any][source]

Converts the function schema to a dictionary.

Returns:

Dictionary representation of the function schema.

property name: str

Get the function name.

Returns:

The function name.

property description: str

Get the function description.

Returns:

The function description.

property properties: dict[str, Any]

Get the function properties.

Returns:

Dictionary of parameter specifications.

property required: list[str]

Get the required parameters.

Returns:

List of required parameter names.

property handler: FunctionCallHandler | None

Get the handler for this function, if any.

Returns:

The handler for this function, or None if it’s provided separately, through register_function.