Skip to main content

PortableTool

Trait PortableTool 

Source
pub trait PortableTool:
    Sized
    + WasmCompatSend
    + WasmCompatSync {
    type Args: for<'de> Deserialize<'de> + WasmCompatSend + WasmCompatSync;
    type Output: IntoToolOutput + WasmCompatSend;
    type Error: Error + WasmCompatSend + WasmCompatSync + 'static;

    const NAME: &'static str;

    // Required methods
    fn description(&self) -> String;
    fn parameters(&self) -> Value;
    fn call(
        &self,
        arguments: Self::Args,
    ) -> impl Future<Output = Result<Self::Output, Self::Error>> + WasmCompatSend;

    // Provided method
    fn map_error(&self, error: Self::Error) -> ToolExecutionError { ... }
}
Expand description

A context-free typed tool that can be executed by any Rig runtime.

Required Associated Constants§

Source

const NAME: &'static str

Unique registration and provider-facing name.

Required Associated Types§

Source

type Args: for<'de> Deserialize<'de> + WasmCompatSend + WasmCompatSync

Owned JSON arguments.

Source

type Output: IntoToolOutput + WasmCompatSend

Canonical model-visible output.

Source

type Error: Error + WasmCompatSend + WasmCompatSync + 'static

Concrete author-facing failure.

Required Methods§

Source

fn description(&self) -> String

Model-facing description.

Source

fn parameters(&self) -> Value

JSON Schema for arguments.

Source

fn call( &self, arguments: Self::Args, ) -> impl Future<Output = Result<Self::Output, Self::Error>> + WasmCompatSend

Execute one owned invocation without runtime access.

Provided Methods§

Source

fn map_error(&self, error: Self::Error) -> ToolExecutionError

Normalize a concrete failure at the runtime effect boundary.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl PortableTool for ThinkTool

Source§

impl<T, F> PortableTool for T
where F: SearchFilter<Value = Value> + WasmCompatSend + WasmCompatSync + for<'de> Deserialize<'de>, T: VectorStoreIndex<Filter = F>,