Trait CreateTextCompletionSession

Source
pub trait CreateTextCompletionSession {
    type Error: Send + Sync + 'static;
    type Session: TextCompletionSession;

    // Required method
    fn new_session(&self) -> Result<Self::Session, Self::Error>;
}
Expand description

A trait for creating a text completion session for a model. While it the core trait every text completion model must implement, most methods to use models that implement this trait are implemented in the TextCompletionModelExt trait.

§Example

use kalosm::language::*;

#[tokio::main]
async fn main() {
    // Create a new model which implements the CreateTextCompletionSession trait
    let mut llm = Llama::new().await.unwrap();
    // Create a new session for the model
    let mut session = llm.new_session().unwrap();
}

Required Associated Types§

Source

type Error: Send + Sync + 'static

The type of error this model may return during operations.

Source

type Session: TextCompletionSession

The type of the session that this model uses.

Required Methods§

Source

fn new_session(&self) -> Result<Self::Session, Self::Error>

Create a new session for this model.

§Example
// Create a new model which implements the CreateTextCompletionSession trait
let llm = Llama::new().await.unwrap();
// Create a new session for the model
let session = llm.new_session().unwrap();

Implementors§