Skip to main content

LanguageModel

Trait LanguageModel 

Source
pub trait LanguageModel {
    // Required methods
    fn generate_text_with_options<P>(
        &self,
        prompt: P,
        options: GenerationOptions,
    ) -> impl Future<Output = Result<ResponseText, Error>> + '_
       where P: TryInto<Prompt>,
             P::Error: Into<Error>;
    fn stream_text_with_options<P>(
        &self,
        prompt: P,
        options: GenerationOptions,
    ) -> Result<ResponseStream, Error>
       where P: TryInto<Prompt>,
             P::Error: Into<Error>;
}
Expand description

Provider-agnostic language-model boundary used by sessions and provider handles.

Required Methods§

Source

fn generate_text_with_options<P>( &self, prompt: P, options: GenerationOptions, ) -> impl Future<Output = Result<ResponseText, Error>> + '_
where P: TryInto<Prompt>, P::Error: Into<Error>,

Generates response text for a prompt with explicit generation options.

§Errors

Implementations return Error when prompt conversion, option validation, session creation, or model generation fails.

Source

fn stream_text_with_options<P>( &self, prompt: P, options: GenerationOptions, ) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Streams response text for a prompt with explicit generation options.

§Errors

Implementations return Error when prompt conversion, option validation, session creation, or stream startup fails.

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§