Skip to main content

CompatibleProvider

Struct CompatibleProvider 

Source
pub struct CompatibleProvider { /* private fields */ }
Expand description

LlmProvider adapter for OpenAI-compatible REST endpoints.

Delegates all operations to an inner OpenAiProvider while exposing a configurable provider_name for logging and routing identification.

Implementations§

Source§

impl CompatibleProvider

Source

pub fn new(cfg: CompatibleConfig) -> Self

Create a new provider from a CompatibleConfig.

Source§

impl CompatibleProvider

Source

pub async fn list_models_remote(&self) -> Result<Vec<RemoteModelInfo>, LlmError>

Fetch models via the inner OpenAiProvider. Cache slug is derived from base URL.

§Errors

Returns an error if the API request fails.

Source§

impl CompatibleProvider

Source

pub fn set_status_tx(&mut self, tx: StatusTx)

Attach a status channel for streaming progress events to the TUI.

Source

pub fn with_generation_overrides(self, overrides: GenerationOverrides) -> Self

Override generation parameters (temperature, top-p, etc.) for all subsequent calls.

Source

pub fn with_output_schema_forwarding( self, enabled: bool, hint_bytes: usize, max_description_bytes: usize, ) -> Self

Forward MCP tool output schemas as JSON hints appended to tool descriptions.

Delegates to the inner OpenAiProvider. When enabled is false the call is a no-op. hint_bytes caps the JSON representation; max_description_bytes caps the combined description string.

Trait Implementations§

Source§

impl Clone for CompatibleProvider

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompatibleProvider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LlmProvider for CompatibleProvider

Source§

fn context_window(&self) -> Option<usize>

Report the model’s context window size in tokens. Read more
Source§

async fn chat(&self, messages: &[Message]) -> Result<String, LlmError>

Send messages to the LLM and return the assistant response. Read more
Source§

async fn chat_with_extras( &self, messages: &[Message], ) -> Result<(String, ChatExtras), LlmError>

Send messages and return the assistant response together with per-call extras. Read more
Source§

async fn chat_stream( &self, messages: &[Message], ) -> Result<ChatStream, LlmError>

Send messages and return a stream of response chunks. Read more
Source§

fn supports_streaming(&self) -> bool

Whether this provider supports native streaming.
Source§

async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError>

Generate an embedding vector from text. Read more
Source§

async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, LlmError>

Embed multiple texts in a single API call. Read more
Source§

fn supports_embeddings(&self) -> bool

Whether this provider supports embedding generation.
Source§

fn name(&self) -> &str

Provider name for logging and identification.
Source§

fn model_identifier(&self) -> &str

Model identifier string (e.g. gpt-4o-mini, claude-sonnet-4-6). Used by cost-estimation heuristics. Returns "" when not applicable.
Source§

fn list_models(&self) -> Vec<String>

Return the list of model identifiers this provider can serve. Default: empty (provider does not advertise models).
Source§

fn supports_structured_output(&self) -> bool

Whether this provider supports native structured output.
Source§

async fn chat_typed<T>(&self, messages: &[Message]) -> Result<T, LlmError>
where T: DeserializeOwned + JsonSchema + 'static, Self: Sized,

Send messages and parse the response into a typed value T. Read more
Source§

async fn chat_with_tools( &self, messages: &[Message], tools: &[ToolDefinition], ) -> Result<ChatResponse, LlmError>

Send messages with tool definitions, returning a structured response. Read more
Source§

fn last_cache_usage(&self) -> Option<(u64, u64)>

Return the cache usage from the last API call, if available. Returns (cache_creation_tokens, cache_read_tokens).
Source§

fn last_usage(&self) -> Option<(u64, u64)>

Return token counts from the last API call, if available. Returns (input_tokens, output_tokens).
Source§

fn debug_request_json( &self, messages: &[Message], tools: &[ToolDefinition], stream: bool, ) -> Value

Return the request payload that will be sent to the provider, for debug dumps. Read more
Source§

fn supports_vision(&self) -> bool

Whether this provider supports image input (vision).
Source§

fn supports_tool_use(&self) -> bool

Whether this provider supports native tool_use / function calling.
Source§

fn last_reasoning_tokens(&self) -> Option<u64>

Return reasoning tokens from the last API call, if the provider reports them. Read more
Source§

fn take_compaction_summary(&self) -> Option<String>

Return the compaction summary from the most recent API call, if a server-side compaction occurred (Claude compact-2026-01-12 beta). Clears the stored value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LlmProviderDyn for T
where T: LlmProvider + Debug + Send + Sync + 'static,

Source§

fn context_window(&self) -> Option<usize>

Report the model’s context window size in tokens. None if unknown.
Source§

fn chat<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'a>>

Send messages to the LLM and return the assistant response. Read more
Source§

fn chat_stream<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>, LlmError>> + Send + 'a>>

Send messages and return a stream of response chunks. Read more
Source§

fn supports_streaming(&self) -> bool

Whether this provider supports native streaming.
Source§

fn embed<'a>( &'a self, text: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, LlmError>> + Send + 'a>>

Generate an embedding vector from text. Read more
Source§

fn embed_batch<'a>( &'a self, texts: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, LlmError>> + Send + 'a>>

Embed multiple texts in a single API call. Read more
Source§

fn supports_embeddings(&self) -> bool

Whether this provider supports embedding generation.
Source§

fn name(&self) -> &str

Provider name for logging and identification.
Source§

fn model_identifier(&self) -> &str

Model identifier string (e.g. gpt-4o-mini, claude-sonnet-4-6).
Source§

fn supports_vision(&self) -> bool

Whether this provider supports image input (vision).
Source§

fn supports_tool_use(&self) -> bool

Whether this provider supports native tool_use / function calling.
Source§

fn chat_with_tools<'a>( &'a self, messages: &'a [Message], tools: &'a [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>

Send messages with tool definitions, returning a structured response. Read more
Source§

fn last_cache_usage(&self) -> Option<(u64, u64)>

Return the cache usage from the last API call, if available. Returns (cache_creation_tokens, cache_read_tokens).
Source§

fn last_usage(&self) -> Option<(u64, u64)>

Return token counts from the last API call, if available. Returns (input_tokens, output_tokens).
Source§

fn take_compaction_summary(&self) -> Option<String>

Return the compaction summary from the most recent API call, if available.
Source§

fn chat_with_extras<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<(String, ChatExtras), LlmError>> + Send + 'a>>

Send messages and return the assistant response together with per-call extras. Read more
Source§

fn debug_request_json( &self, messages: &[Message], tools: &[ToolDefinition], stream: bool, ) -> Value

Return the request payload that will be sent to the provider, for debug dumps.
Source§

fn list_models(&self) -> Vec<String>

Return the list of model identifiers this provider can serve.
Source§

fn supports_structured_output(&self) -> bool

Whether this provider supports native structured output.
Source§

fn last_reasoning_tokens(&self) -> Option<u64>

Return reasoning tokens from the last API call, if the provider reports them. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more