CompletionClient

Trait CompletionClient 

Source
pub trait CompletionClient: ProviderClient + Clone {
    type CompletionModel: CompletionModel;

    // Required method
    fn completion_model(&self, model: &str) -> Self::CompletionModel;

    // Provided methods
    fn agent(&self, model: &str) -> AgentBuilder<Self::CompletionModel> { ... }
    fn extractor<T: JsonSchema + for<'a> Deserialize<'a> + Serialize + Send + Sync>(
        &self,
        model: &str,
    ) -> ExtractorBuilder<T, Self::CompletionModel> { ... }
}
Expand description

A provider client with completion capabilities. Clone is required for conversions between client types.

Required Associated Types§

Source

type CompletionModel: CompletionModel

The type of CompletionModel used by the client.

Required Methods§

Source

fn completion_model(&self, model: &str) -> Self::CompletionModel

Create a completion model with the given name.

§Example with OpenAI
use rig::prelude::*;
use rig::providers::openai::{Client, self};

// Initialize the OpenAI client
let openai = Client::new("your-open-ai-api-key");

let gpt4 = openai.completion_model(openai::GPT_4);

Provided Methods§

Source

fn agent(&self, model: &str) -> AgentBuilder<Self::CompletionModel>

Create an agent builder with the given completion model.

§Example with OpenAI
use rig::prelude::*;
use rig::providers::openai::{Client, self};

// Initialize the OpenAI client
let openai = Client::new("your-open-ai-api-key");

let agent = openai.agent(openai::GPT_4)
   .preamble("You are comedian AI with a mission to make people laugh.")
   .temperature(0.0)
   .build();
Source

fn extractor<T: JsonSchema + for<'a> Deserialize<'a> + Serialize + Send + Sync>( &self, model: &str, ) -> ExtractorBuilder<T, Self::CompletionModel>

Create an extractor builder with the given completion model.

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.

Implementors§

Source§

impl CompletionClient for rig::providers::anthropic::client::Client

Source§

impl CompletionClient for rig::providers::azure::Client

Source§

impl CompletionClient for rig::providers::cohere::client::Client

Source§

impl CompletionClient for rig::providers::deepseek::Client

Source§

impl CompletionClient for rig::providers::galadriel::Client

Source§

impl CompletionClient for rig::providers::gemini::client::Client

Source§

impl CompletionClient for rig::providers::groq::Client

Source§

impl CompletionClient for rig::providers::huggingface::client::Client

Source§

impl CompletionClient for rig::providers::hyperbolic::Client

Source§

impl CompletionClient for rig::providers::mira::Client

Source§

impl CompletionClient for rig::providers::mistral::client::Client

Source§

impl CompletionClient for rig::providers::moonshot::Client

Source§

impl CompletionClient for rig::providers::ollama::Client

Source§

impl CompletionClient for rig::providers::openai::client::Client

Source§

impl CompletionClient for rig::providers::openrouter::client::Client

Source§

impl CompletionClient for rig::providers::perplexity::Client

Source§

impl CompletionClient for rig::providers::together::client::Client

Source§

impl CompletionClient for rig::providers::xai::client::Client