Module function

Source
Expand description

Function module for OpenAI tools.

This module provides the Function struct and related functionality for representing and working with OpenAI function calls. Functions are used to define callable operations that can be invoked by OpenAI’s API, including their parameters, descriptions, and execution modes.

The Function struct is a core component that is used throughout the OpenAI tools library:

§Key Features

  • Serialization/Deserialization: Custom implementations for clean JSON output
  • Flexible Parameters: Support for complex parameter schemas via crate::common::parameters::Parameters
  • Argument Handling: Support for both JSON string and structured argument formats
  • Strict Mode: Optional strict execution mode for enhanced validation

§Usage Patterns

Functions are typically used in two main contexts:

  1. Tool Definition: When creating tools that OpenAI models can call
  2. Function Execution: When processing function calls from OpenAI responses

Structs§

Function
Represents a function that can be called by OpenAI tools.