pub trait Backend: Send + Sync {
// Required methods
fn generate<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<BackendGenerationResponse, ProtocolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn generate_stream<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<NotificationStream<BackendGenerationResponse>, ProtocolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
The backend service which the core uses to generate text. Implements a low-level interface for interacting with language models.
Required Methods§
Sourcefn generate<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<BackendGenerationResponse, ProtocolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<BackendGenerationResponse, ProtocolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate text and return the whole response.
Sourcefn generate_stream<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<NotificationStream<BackendGenerationResponse>, ProtocolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_stream<'life0, 'async_trait>(
&'life0 self,
request: BackendGenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<NotificationStream<BackendGenerationResponse>, ProtocolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Request text generation and return an asynchronous stream of generated tokens.