Skip to main content

ProviderToolFormatter

Trait ProviderToolFormatter 

Source
pub trait ProviderToolFormatter: Send + Sync {
    // Required methods
    fn family(&self) -> ProviderFamily;
    fn supported_extensions(&self) -> &'static [&'static str];
    fn supports(&self, tool: &ToolDefinition) -> bool;
    fn format_tools(
        &self,
        tools: &[ToolDefinition],
        model: &str,
    ) -> Result<Option<Value>, LLMError>;
}
Expand description

Trait implemented by every provider tool formatter.

Implementations are expected to be stateless. Constructors live in formatters below.

Required Methods§

Source

fn family(&self) -> ProviderFamily

Family this formatter belongs to (for diagnostics).

Source

fn supported_extensions(&self) -> &'static [&'static str]

Provider extensions preserved by this formatter. Used by callers that want to validate that a particular extension (e.g. defer_loading) is supported before passing a tool through.

Source

fn supports(&self, tool: &ToolDefinition) -> bool

Returns true when this formatter accepts the given tool type unchanged.

Source

fn format_tools( &self, tools: &[ToolDefinition], model: &str, ) -> Result<Option<Value>, LLMError>

Format a slice of tool definitions into the wire-shape this provider expects.

Returns None when the slice is empty (mirrors the existing per-provider helpers).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§