Skip to main content

CompletionProvider

Trait CompletionProvider 

Source
pub trait CompletionProvider: Send + Sync {
    // Required method
    fn complete<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        messages: &'life1 mut Messages,
        tool_declarations: Option<&'life2 dyn ToolDeclarations>,
        options: Option<&'life3 ChatOptions>,
        structured_output: Option<&'life4 Schema>,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, ChatFailure>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;

    // Provided method
    fn metadata(&self) -> Option<&ProviderMeta> { ... }
}
Expand description

Tool declarations are the one and only view providers have into the user’s tool collections. The trait intentionally exposes nothing about execution, metadata, or strategy — providers translate declarations to their wire format and nothing else. For the builder-side collection API, see crate::types::tools.

Required Methods§

Source

fn complete<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, messages: &'life1 mut Messages, tool_declarations: Option<&'life2 dyn ToolDeclarations>, options: Option<&'life3 ChatOptions>, structured_output: Option<&'life4 Schema>, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, ChatFailure>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run one completion step.

tool_declarations, when Some, is a view onto every scoped tool collection the chat loop holds. Call .json() on it to get the JSON array of function declarations that providers splice into their native request format.

Provided Methods§

Implementors§