ToolEmbedding

Trait ToolEmbedding 

Source
pub trait ToolEmbedding: Tool {
    type InitError: Error + Send + Sync + 'static;
    type Context: for<'a> Deserialize<'a> + Serialize;
    type State: Send;

    // Required methods
    fn embedding_docs(&self) -> Vec<String>;
    fn context(&self) -> Self::Context;
    fn init(
        state: Self::State,
        context: Self::Context,
    ) -> Result<Self, Self::InitError>;
}
Expand description

Trait that represents an LLM tool that can be stored in a vector store and RAGged

Required Associated Types§

Source

type InitError: Error + Send + Sync + 'static

Source

type Context: for<'a> Deserialize<'a> + Serialize

Type of the tool’ context. This context will be saved and loaded from the vector store when ragging the tool. This context can be used to store the tool’s static configuration and local context.

Source

type State: Send

Type of the tool’s state. This state will be passed to the tool when initializing it. This state can be used to pass runtime arguments to the tool such as clients, API keys and other configuration.

Required Methods§

Source

fn embedding_docs(&self) -> Vec<String>

A method returning the documents that will be used as embeddings for the tool. This allows for a tool to be retrieved from multiple embedding “directions”. If the tool will not be RAGged, this method should return an empty vector.

Source

fn context(&self) -> Self::Context

A method returning the context of the tool.

Source

fn init( state: Self::State, context: Self::Context, ) -> Result<Self, Self::InitError>

A method to initialize the tool from the context, and a state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§