pub struct ToolDefinition {
pub name: &'static str,
pub description: String,
pub parameters: Value,
}Expand description
A provider-neutral tool definition.
parameters is a JSON Schema object; every major LLM API takes that shape,
under whatever key it calls it.
Fields§
§name: &'static strThe tool name the model calls.
description: StringWhat the tool does, as the model sees it.
parameters: ValueJSON Schema for the tool’s arguments.
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn to_anthropic_value(&self) -> Value
pub fn to_anthropic_value(&self) -> Value
Renders the definition in Anthropic’s Messages API shape:
{name, description, input_schema}.
Named for the provider because the key is: Anthropic calls the schema
input_schema, OpenAI nests it under function.parameters, and Gemini
wants parameters with a restricted subset of JSON Schema. The struct’s
own fields are the provider-neutral form; reach for those, or for
ag_ui::Tool
via From under the ag-ui feature, when the target is anything else.
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolDefinition
impl Debug for ToolDefinition
Source§impl From<ToolDefinition> for Tool
Offers a toolkit tool definition on an AG-UI run.
impl From<ToolDefinition> for Tool
Offers a toolkit tool definition on an AG-UI run.
Source§fn from(definition: ToolDefinition) -> Self
fn from(definition: ToolDefinition) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ToolDefinition
impl PartialEq for ToolDefinition
Source§fn eq(&self, other: &ToolDefinition) -> bool
fn eq(&self, other: &ToolDefinition) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ToolDefinition
Auto Trait Implementations§
impl Freeze for ToolDefinition
impl RefUnwindSafe for ToolDefinition
impl Send for ToolDefinition
impl Sync for ToolDefinition
impl Unpin for ToolDefinition
impl UnsafeUnpin for ToolDefinition
impl UnwindSafe for ToolDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more