pub struct OpenAiCompatAdapter { /* private fields */ }Expand description
HTTP adapter for any OpenAI-compatible /v1/chat/completions server.
Construct via OpenAiCompatAdapter::new. The adapter is Send + Sync
and may be held behind an Arc<dyn LlmAdapter>.
Implementations§
Source§impl OpenAiCompatAdapter
impl OpenAiCompatAdapter
Sourcepub fn new(
base_url: impl Into<String>,
model: impl Into<String>,
api_key: Option<String>,
timeout_ms: u64,
max_sensitivity: Option<MaxSensitivity>,
) -> Result<Self, LlmError>
pub fn new( base_url: impl Into<String>, model: impl Into<String>, api_key: Option<String>, timeout_ms: u64, max_sensitivity: Option<MaxSensitivity>, ) -> Result<Self, LlmError>
Construct an adapter.
api_key accepts None or an empty-string Some(""); both result in
no Authorization header being sent.
max_sensitivity controls the data-classification gate before remote
dispatch. Pass None to use the default of MaxSensitivity::Medium,
which blocks high-sensitivity memories from being sent to the endpoint.
A warning is printed to stderr when base_url resolves to a non-loopback
host, because all prompt content will be sent to that remote server.
Returns LlmError::InvalidRequest when:
base_urldoes not start withhttp://orhttps://.base_urlcontains no host.modelis empty.
Sourcepub fn runtime_ceiling(&self) -> RuntimeCeiling
pub fn runtime_ceiling(&self) -> RuntimeCeiling
Return the runtime ceiling determined at construction from base_url.
Trait Implementations§
Source§impl Clone for OpenAiCompatAdapter
impl Clone for OpenAiCompatAdapter
Source§fn clone(&self) -> OpenAiCompatAdapter
fn clone(&self) -> OpenAiCompatAdapter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenAiCompatAdapter
impl Debug for OpenAiCompatAdapter
Source§impl LlmAdapter for OpenAiCompatAdapter
impl LlmAdapter for OpenAiCompatAdapter
Source§fn stream_boxed(&self, req: LlmRequest) -> BoxStream<'_>
fn stream_boxed(&self, req: LlmRequest) -> BoxStream<'_>
Override with true OpenAI SSE streaming via POST /v1/chat/completions
with "stream": true.
Parses data: lines, extracts choices[0].delta.content, and skips
the terminal data: [DONE] sentinel.
Source§fn adapter_id(&self) -> &'static str
fn adapter_id(&self) -> &'static str
"claude",
"ollama", "replay"). Constants — implementations MUST NOT vary
this per call.Source§fn complete<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
req.timeout_ms and returning LlmError::Timeout when exceeded.