Trait CompletionModel

Source
pub trait CompletionModel: Send {
    // Required methods
    fn build_client(
        self,
        preamble: impl AsRef<str>,
        embedder_instances: Vec<Embedder>,
        tools: ToolSet,
    ) -> Client<impl CompletionModel>;
    fn send<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        message: Message,
        history: &'life1 Vec<Message>,
        tools: Option<&'life2 ToolSet>,
        temperature: f64,
        max_tokens: usize,
    ) -> Pin<Box<dyn Future<Output = Result<(Message, TokenUsage), CompletionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn extract<'life0, 'life1, 'async_trait, T>(
        &'life0 mut self,
        message: Message,
        history: &'life1 Vec<Message>,
        temperature: f64,
        max_tokens: usize,
    ) -> Pin<Box<dyn Future<Output = Result<T, CompletionError>> + Send + 'async_trait>>
       where T: 'async_trait + Extractor,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Core trait defining the interface for completion models

Required Methods§

Source

fn build_client( self, preamble: impl AsRef<str>, embedder_instances: Vec<Embedder>, tools: ToolSet, ) -> Client<impl CompletionModel>

Constructs a new Client with this model

§Arguments
  • preamble - System prompt/instructions for the model
  • embedder_instances - Embedding models for context retrieval
  • tools - Collection of available tools
Source

fn send<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, message: Message, history: &'life1 Vec<Message>, tools: Option<&'life2 ToolSet>, temperature: f64, max_tokens: usize, ) -> Pin<Box<dyn Future<Output = Result<(Message, TokenUsage), CompletionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sends a message to the model and returns its response

§Arguments
  • message - The message to process
  • history - Conversation context
  • tools - Optional toolset for function calling
  • temperature - Sampling temperature (0.0-1.0)
  • max_tokens - Maximum tokens to be used

Provided Methods§

Source

fn extract<'life0, 'life1, 'async_trait, T>( &'life0 mut self, message: Message, history: &'life1 Vec<Message>, temperature: f64, max_tokens: usize, ) -> Pin<Box<dyn Future<Output = Result<T, CompletionError>> + Send + 'async_trait>>
where T: 'async_trait + Extractor, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extracts structured data from a model response

Default implementation returns ExtractionError::ExtractionNotSupported unless overridden by the model implementation.

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§