pub trait LanguageModel:
Sized
+ Send
+ Sync
+ 'static {
type Error: Error + Send + Sync + 'static;
// Required methods
fn respond(&self, request: Request) -> impl TextStream<Error = Self::Error>;
fn complete(&self, prefix: &str) -> impl TextStream<Error = Self::Error>;
fn profile(&self) -> Profile;
// Provided methods
fn generate<T: JsonSchema + DeserializeOwned>(
&self,
request: Request,
) -> impl Future<Output = Result<T>> + Send { ... }
fn summarize(&self, text: &str) -> impl TextStream<Error = Self::Error> { ... }
fn categorize<T: JsonSchema + DeserializeOwned>(
&self,
text: &str,
) -> impl Future<Output = Result<T>> + Send { ... }
}
Expand description
Language models for text generation and conversation.
See the module documentation for examples and usage patterns.
Required Associated Types§
Required Methods§
Sourcefn respond(&self, request: Request) -> impl TextStream<Error = Self::Error>
fn respond(&self, request: Request) -> impl TextStream<Error = Self::Error>
Generates streaming response to conversation.
Sourcefn complete(&self, prefix: &str) -> impl TextStream<Error = Self::Error>
fn complete(&self, prefix: &str) -> impl TextStream<Error = Self::Error>
Completes given text prefix.
Provided Methods§
Sourcefn generate<T: JsonSchema + DeserializeOwned>(
&self,
request: Request,
) -> impl Future<Output = Result<T>> + Send
fn generate<T: JsonSchema + DeserializeOwned>( &self, request: Request, ) -> impl Future<Output = Result<T>> + Send
Generates structured output conforming to JSON schema.
Sourcefn summarize(&self, text: &str) -> impl TextStream<Error = Self::Error>
fn summarize(&self, text: &str) -> impl TextStream<Error = Self::Error>
Summarizes text.
Sourcefn categorize<T: JsonSchema + DeserializeOwned>(
&self,
text: &str,
) -> impl Future<Output = Result<T>> + Send
fn categorize<T: JsonSchema + DeserializeOwned>( &self, text: &str, ) -> impl Future<Output = Result<T>> + Send
Categorizes text.
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.