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§
Sourcefn build_client(
self,
preamble: impl AsRef<str>,
embedder_instances: Vec<Embedder>,
tools: ToolSet,
) -> Client<impl CompletionModel>
fn build_client( self, preamble: impl AsRef<str>, embedder_instances: Vec<Embedder>, tools: ToolSet, ) -> Client<impl CompletionModel>
Sourcefn 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,
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 processhistory
- Conversation contexttools
- Optional toolset for function callingtemperature
- Sampling temperature (0.0-1.0)max_tokens
- Maximum tokens to be used
Provided Methods§
Sourcefn 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,
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.