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§
Sourcefn family(&self) -> ProviderFamily
fn family(&self) -> ProviderFamily
Family this formatter belongs to (for diagnostics).
Sourcefn supported_extensions(&self) -> &'static [&'static str]
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.
Sourcefn supports(&self, tool: &ToolDefinition) -> bool
fn supports(&self, tool: &ToolDefinition) -> bool
Returns true when this formatter accepts the given tool type unchanged.
Sourcefn format_tools(
&self,
tools: &[ToolDefinition],
model: &str,
) -> Result<Option<Value>, LLMError>
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".