Skip to main content

Module completion

Module completion 

Source
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§

CompletionRequest
Everything a completion model needs to generate a response.
CompletionResponse
The full response returned by a CompletionModel.
Usage
Token usage reported by the provider (optional — not all providers expose this).

Enums§

CompletionError
Errors that can occur during a completion request.
ModelChoice
The model’s choice of response for a single completion turn.

Traits§

CompletionModel
The core abstraction for any text-generation model.