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:
- In
crate::common::message
- Used withinToolCall
structures to represent function calls in messages - In
crate::common::tool
- Used withinTool
structures to define available functions for OpenAI models - In
crate::chat::request
- Used in Chat Completion API requests for function calling capabilities - In
crate::responses::request
- Used in Responses API requests for structured interactions
§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:
- Tool Definition: When creating tools that OpenAI models can call
- Function Execution: When processing function calls from OpenAI responses
Structs§
- Function
- Represents a function that can be called by OpenAI tools.