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
impl CompatibleProvider
Sourcepub fn new(cfg: CompatibleConfig) -> Self
pub fn new(cfg: CompatibleConfig) -> Self
Create a new provider from a CompatibleConfig.
Source§impl CompatibleProvider
impl CompatibleProvider
Sourcepub async fn list_models_remote(&self) -> Result<Vec<RemoteModelInfo>, LlmError>
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
impl CompatibleProvider
Sourcepub fn set_status_tx(&mut self, tx: StatusTx)
pub fn set_status_tx(&mut self, tx: StatusTx)
Attach a status channel for streaming progress events to the TUI.
Sourcepub fn with_generation_overrides(self, overrides: GenerationOverrides) -> Self
pub fn with_generation_overrides(self, overrides: GenerationOverrides) -> Self
Override generation parameters (temperature, top-p, etc.) for all subsequent calls.
Sourcepub fn with_completion_tokens_param(self, param: CompletionTokensParam) -> Self
pub fn with_completion_tokens_param(self, param: CompletionTokensParam) -> Self
Override which token-limit parameter is sent in API requests.
Delegates to the inner OpenAiProvider. Use this when the model name is not covered
by the built-in prefix table and the inferred field would produce a 400 error.
§Examples
use zeph_llm::compatible::{CompatibleConfig, CompatibleProvider};
use zeph_llm::openai::CompletionTokensParam;
let provider = CompatibleProvider::new(CompatibleConfig {
provider_name: "my-provider".into(),
api_key: "key".into(),
base_url: "https://api.example.com/v1".into(),
model: "my-ft-reasoner-v1".into(),
max_tokens: 4096,
embedding_model: None,
completion_tokens_param: None,
vision: None,
})
.with_completion_tokens_param(CompletionTokensParam::MaxCompletionTokens);Sourcepub fn with_vision(self, supported: bool) -> Self
pub fn with_vision(self, supported: bool) -> Self
Override the vision-capability value reported by LlmProvider::supports_vision.
Delegates to the inner OpenAiProvider. Use this for compatible endpoints whose
model name is not covered by OpenAiProvider’s built-in prefix table — which is the
common case, since third-party model names carry no OpenAI naming convention and the
table therefore fails safe to false for them.
§Examples
use zeph_llm::compatible::{CompatibleConfig, CompatibleProvider};
use zeph_llm::provider::LlmProvider;
let provider = CompatibleProvider::new(CompatibleConfig {
provider_name: "local-vlm".into(),
api_key: "key".into(),
base_url: "http://localhost:8000/v1".into(),
model: "llava-onevision".into(),
max_tokens: 4096,
embedding_model: None,
completion_tokens_param: None,
vision: None,
})
.with_vision(true);
assert!(provider.supports_vision());Sourcepub fn with_output_schema_forwarding(
self,
enabled: bool,
hint_bytes: usize,
max_description_bytes: usize,
) -> Self
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.
Sourcepub fn set_reasoning_effort(&mut self, effort: Option<String>)
pub fn set_reasoning_effort(&mut self, effort: Option<String>)
Apply a reasoning_effort override to the inner OpenAiProvider.
Delegates to OpenAiProvider::set_reasoning_effort, which validates the value
("low", "medium", or "high") and logs a warning for any unknown value.
Pass None to clear a previously-set effort level.
Sourcepub fn current_reasoning_effort(&self) -> Option<String>
pub fn current_reasoning_effort(&self) -> Option<String>
Return the currently configured reasoning_effort value on the inner
OpenAiProvider, if any.
Trait Implementations§
Source§impl Clone for CompatibleProvider
impl Clone for CompatibleProvider
Source§impl Debug for CompatibleProvider
impl Debug for CompatibleProvider
Source§impl LlmProvider for CompatibleProvider
impl LlmProvider for CompatibleProvider
Source§fn context_window(&self) -> Option<usize>
fn context_window(&self) -> Option<usize>
Source§async fn chat(&self, messages: &[Message]) -> Result<String, LlmError>
async fn chat(&self, messages: &[Message]) -> Result<String, LlmError>
Source§async fn chat_with_extras(
&self,
messages: &[Message],
) -> Result<(String, ChatExtras), LlmError>
async fn chat_with_extras( &self, messages: &[Message], ) -> Result<(String, ChatExtras), LlmError>
Source§async fn chat_stream(
&self,
messages: &[Message],
) -> Result<ChatStream, LlmError>
async fn chat_stream( &self, messages: &[Message], ) -> Result<ChatStream, LlmError>
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Source§async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError>
async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError>
Source§async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, LlmError>
async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, LlmError>
Source§fn supports_embeddings(&self) -> bool
fn supports_embeddings(&self) -> bool
Source§fn model_identifier(&self) -> &str
fn model_identifier(&self) -> &str
gpt-4o-mini, claude-sonnet-5).
Used by cost-estimation heuristics. Returns "" when not applicable.Source§fn list_models(&self) -> Vec<String>
fn list_models(&self) -> Vec<String>
Source§fn supports_structured_output(&self) -> bool
fn supports_structured_output(&self) -> bool
Source§async fn chat_typed<T>(&self, messages: &[Message]) -> Result<T, LlmError>
async fn chat_typed<T>(&self, messages: &[Message]) -> Result<T, LlmError>
T. Read moreSource§async fn chat_with_tools(
&self,
messages: &[Message],
tools: &[ToolDefinition],
) -> Result<ChatResponse, LlmError>
async fn chat_with_tools( &self, messages: &[Message], tools: &[ToolDefinition], ) -> Result<ChatResponse, LlmError>
Source§fn last_cache_usage(&self) -> Option<(u64, u64)>
fn last_cache_usage(&self) -> Option<(u64, u64)>
(cache_creation_tokens, cache_read_tokens).Source§fn last_usage(&self) -> Option<(u64, u64)>
fn last_usage(&self) -> Option<(u64, u64)>
(input_tokens, output_tokens).Source§fn last_reasoning_tokens(&self) -> Option<u64>
fn last_reasoning_tokens(&self) -> Option<u64>
Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Source§fn supports_tool_use(&self) -> bool
fn supports_tool_use(&self) -> bool
tool_use / function calling. Read moreSource§fn debug_request_json(
&self,
messages: &[Message],
tools: &[ToolDefinition],
stream: bool,
) -> Value
fn debug_request_json( &self, messages: &[Message], tools: &[ToolDefinition], stream: bool, ) -> Value
Source§fn effective_model_identifier(&self) -> &str
fn effective_model_identifier(&self) -> &str
Source§fn last_ttft_ms(&self) -> Option<u64>
fn last_ttft_ms(&self) -> Option<u64>
Source§fn take_compaction_summary(&self) -> Option<String>
fn take_compaction_summary(&self) -> Option<String>
Auto Trait Implementations§
impl !Freeze for CompatibleProvider
impl !RefUnwindSafe for CompatibleProvider
impl !UnwindSafe for CompatibleProvider
impl Send for CompatibleProvider
impl Sync for CompatibleProvider
impl Unpin for CompatibleProvider
impl UnsafeUnpin for CompatibleProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LlmProviderDyn for T
impl<T> LlmProviderDyn for T
Source§fn context_window(&self) -> Option<usize>
fn context_window(&self) -> Option<usize>
None if unknown.Source§fn chat<'a>(
&'a self,
messages: &'a [Message],
) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'a>>
fn chat<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'a>>
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>>
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>>
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Source§fn embed<'a>(
&'a self,
text: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, LlmError>> + Send + 'a>>
fn embed<'a>( &'a self, text: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, LlmError>> + Send + 'a>>
Source§fn embed_batch<'a>(
&'a self,
texts: &'a [&'a str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, LlmError>> + Send + 'a>>
fn embed_batch<'a>( &'a self, texts: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, LlmError>> + Send + 'a>>
Source§fn supports_embeddings(&self) -> bool
fn supports_embeddings(&self) -> bool
Source§fn model_identifier(&self) -> &str
fn model_identifier(&self) -> &str
gpt-4o-mini, claude-sonnet-5).Source§fn effective_model_identifier(&self) -> &str
fn effective_model_identifier(&self) -> &str
LlmProvider::effective_model_identifier for the full contract.Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Source§fn supports_tool_use(&self) -> bool
fn supports_tool_use(&self) -> bool
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>>
fn chat_with_tools<'a>( &'a self, messages: &'a [Message], tools: &'a [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
Source§fn last_cache_usage(&self) -> Option<(u64, u64)>
fn last_cache_usage(&self) -> Option<(u64, u64)>
(cache_creation_tokens, cache_read_tokens).Source§fn last_usage(&self) -> Option<(u64, u64)>
fn last_usage(&self) -> Option<(u64, u64)>
(input_tokens, output_tokens).