pub struct OpenAiCompatibleClient { /* private fields */ }Expand description
Client for the OpenAI chat-completions protocol.
Also serves every OpenAI-compatible endpoint (Ollama, vLLM, LM Studio,
a compatible proxy) — point base_url at it and keep the protocol.
Implementations§
Source§impl OpenAiCompatibleClient
impl OpenAiCompatibleClient
Sourcepub fn new(
base_url: impl Into<String>,
model: impl Into<String>,
api_key: impl Into<String>,
) -> Result<Self, AgentError>
pub fn new( base_url: impl Into<String>, model: impl Into<String>, api_key: impl Into<String>, ) -> Result<Self, AgentError>
Build a client. The key never leaves this struct except as a header.
§Errors
Returns AgentError when the underlying HTTP client cannot be built.
Sourcepub fn with_timeout(self, timeout: Duration) -> Result<Self, AgentError>
pub fn with_timeout(self, timeout: Duration) -> Result<Self, AgentError>
Replace the request timeout.
§Errors
Returns AgentError when the underlying HTTP client cannot be rebuilt.
Trait Implementations§
Source§impl Debug for OpenAiCompatibleClient
impl Debug for OpenAiCompatibleClient
Source§impl LlmClient for OpenAiCompatibleClient
impl LlmClient for OpenAiCompatibleClient
Source§fn chat<'a>(
&'a self,
request: &'a ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, AgentError>> + Send + 'a>>
fn chat<'a>( &'a self, request: &'a ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, AgentError>> + Send + 'a>>
Send one chat request and decode the response.
Source§fn list_models(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, AgentError>> + Send + '_>>
fn list_models( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, AgentError>> + Send + '_>>
List available model ids. Cheap and read-only: the health check uses it.
Source§fn provider_name(&self) -> &'static str
fn provider_name(&self) -> &'static str
Human-readable provider name for logs and health details.
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAiCompatibleClient
impl !UnwindSafe for OpenAiCompatibleClient
impl Forget for OpenAiCompatibleClient
impl Freeze for OpenAiCompatibleClient
impl Send for OpenAiCompatibleClient
impl Sync for OpenAiCompatibleClient
impl Unpin for OpenAiCompatibleClient
impl UnsafeUnpin for OpenAiCompatibleClient
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
Open a deferred
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.