pub trait Completion {
type Response: Send + Sync + ResponseContent + ResponseToolCalls;
// Required method
fn completion(
&mut self,
request: Request,
) -> impl Future<Output = Result<Self::Response, CompletionError>>;
}Expand description
A trait defining the behavior of a completion engine.
This trait is used by components that handle requests for text generation (or similar completions) and generate responses asynchronously.
§Associated Types
Response: The specific type of the response generated by the completion engine.
Required Associated Types§
Sourcetype Response: Send + Sync + ResponseContent + ResponseToolCalls
type Response: Send + Sync + ResponseContent + ResponseToolCalls
The type of response returned by the completion method.
Required Methods§
Sourcefn completion(
&mut self,
request: Request,
) -> impl Future<Output = Result<Self::Response, CompletionError>>
fn completion( &mut self, request: Request, ) -> impl Future<Output = Result<Self::Response, CompletionError>>
Processes a Request and returns the generated response asynchronously.
§Arguments
request: The request object containing the prompt and additional configuration.
§Returns
A future that resolves to either:
Ok(Self::Response): The generated response.Err(CompletionError): An error encountered during the request processing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".