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§
Sourcetype Chunk: StreamChunkExt
type Chunk: StreamChunkExt
The deserialized stream chunk type for this provider.
Required Methods§
Sourcefn build_request_json(
model: &str,
messages: &[JsonValue],
skill_content: &str,
tools_json: &JsonValue,
) -> JsonValue
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.
Sourcefn create_stream(
client: &Client<OpenAIConfig>,
request_json: JsonValue,
) -> impl Future<Output = Result<StreamResponse<Self::Chunk>, OpenAIError>> + Send
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".