Skip to main content

Model

Trait Model 

Source
pub trait Model: Send + Sync {
    // Required methods
    fn generate(
        &self,
        request: &ChatRequest,
    ) -> impl Future<Output = Result<ChatResponse>> + Send;
    fn generate_stream(
        &self,
        request: &ChatRequest,
    ) -> impl Future<Output = Result<ResponseStream>> + Send;
}
Expand description

Trait for LLM providers. Supports both synchronous and streaming generation.

Implement this trait to add a new model provider to Daimon. The trait is object-safe via ErasedModel, so providers can be stored behind Arc<dyn ErasedModel>.

Required Methods§

Source

fn generate( &self, request: &ChatRequest, ) -> impl Future<Output = Result<ChatResponse>> + Send

Generates a complete response for the given request.

Source

fn generate_stream( &self, request: &ChatRequest, ) -> impl Future<Output = Result<ResponseStream>> + Send

Returns a stream of response chunks for token-by-token output.

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§