pub struct ToolDefinition {
pub name: &'static str,
pub description: &'static str,
pub parameters: &'static str,
}Expand description
Definition of a tool that can be called by an LLM.
This struct holds the metadata about a tool: its name, description, and JSON Schema for parameters. It’s used for:
- Generating OpenAI/Anthropic-compatible tool specifications
- Validating input arguments
- Documentation
§Example
use vex_llm::ToolDefinition;
const SEARCH_TOOL: ToolDefinition = ToolDefinition {
name: "web_search",
description: "Search the web for information",
parameters: r#"{"type": "object", "properties": {"query": {"type": "string"}}}"#,
};Fields§
§name: &'static strName of the tool (used in function calling) Must be unique within a registry
description: &'static strHuman-readable description of what the tool does
parameters: &'static strJSON Schema for the tool’s parameters
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub const fn new(
name: &'static str,
description: &'static str,
parameters: &'static str,
) -> Self
pub const fn new( name: &'static str, description: &'static str, parameters: &'static str, ) -> Self
Create a new tool definition
Sourcepub fn to_openai_format(&self) -> Value
pub fn to_openai_format(&self) -> Value
Convert to OpenAI-compatible tool format
Sourcepub fn to_anthropic_format(&self) -> Value
pub fn to_anthropic_format(&self) -> Value
Convert to Anthropic Claude-compatible tool format
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 · 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 Deserialize<'static> for ToolDefinition
impl Deserialize<'static> for ToolDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ToolDefinition
impl RefUnwindSafe for ToolDefinition
impl Send for ToolDefinition
impl Sync for ToolDefinition
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more