Expand description
Completion model trait and associated request/response types.
CompletionModel is the single interface that provider implementations
must satisfy. The Agent and any other high-level
construct in this crate are generic over it.
§Implementing a provider
ⓘ
use irig::completion::{
CompletionModel, CompletionRequest, CompletionResponse, CompletionError,
};
pub struct MyModel<H> {
client: H,
model: String,
api_key: String,
}
impl<H: HttpClient> CompletionModel for MyModel<H> {
type Error = CompletionError;
async fn complete(
&self,
request: CompletionRequest,
) -> Result<CompletionResponse, Self::Error> {
// 1. Serialise `request` into the provider's API format.
// 2. Call `self.client.post(...)`.
// 3. Deserialise the response into `CompletionResponse`.
todo!()
}
}Structs§
- Completion
Request - Everything a completion model needs to generate a response.
- Completion
Response - The full response returned by a
CompletionModel. - Usage
- Token usage reported by the provider (optional — not all providers expose this).
Enums§
- Completion
Error - Errors that can occur during a completion request.
- Model
Choice - The model’s choice of response for a single completion turn.
Traits§
- Completion
Model - The core abstraction for any text-generation model.