Skip to main content

ChatProvider

Trait ChatProvider 

Source
pub trait ChatProvider:
    Send
    + Sync
    + 'static {
    type Chunk: StreamChunkExt;

    // Required methods
    fn build_request_json(
        model: &str,
        messages: &[JsonValue],
        skill_content: &str,
        tools_json: &JsonValue,
    ) -> JsonValue;
    fn create_stream(
        client: &Client<OpenAIConfig>,
        request_json: JsonValue,
    ) -> impl Future<Output = Result<StreamResponse<Self::Chunk>, OpenAIError>> + Send;
}
Expand description

Abstraction over an LLM backend.

Implementations handle provider-specific request construction and stream deserialization. Two built-in implementations exist: OpenAIProvider (requires openai feature) and DeepSeekProvider (requires deepseek feature).

Required Associated Types§

Source

type Chunk: StreamChunkExt

The deserialized stream chunk type for this provider.

Required Methods§

Source

fn build_request_json( model: &str, messages: &[JsonValue], skill_content: &str, tools_json: &JsonValue, ) -> JsonValue

Build the JSON request body sent to the LLM API.

Merges conversation messages, active skill content (as a system message), and tool definitions into the provider’s expected format.

Source

fn create_stream( client: &Client<OpenAIConfig>, request_json: JsonValue, ) -> impl Future<Output = Result<StreamResponse<Self::Chunk>, OpenAIError>> + Send

Create a streaming completion request.

Returns a StreamResponse of provider-specific chunks that will be consumed by the ReAct loop.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§