pub struct OpenAiProvider { /* private fields */ }Implementations§
Source§impl OpenAiProvider
impl OpenAiProvider
pub fn new( base_url: impl Into<String>, api_key: impl Into<String>, model: impl Into<String>, ) -> Self
Sourcepub fn with_stream_tx(self, tx: StreamSender) -> Self
pub fn with_stream_tx(self, tx: StreamSender) -> Self
Enable streaming by providing a channel sender for partial tokens.
pub fn with_temperature(self, t: f64) -> Self
pub fn with_max_tokens(self, n: u32) -> Self
pub fn with_retry_policy(self, policy: RetryPolicy) -> Self
Trait Implementations§
Source§impl Clone for OpenAiProvider
impl Clone for OpenAiProvider
Source§fn clone(&self) -> OpenAiProvider
fn clone(&self) -> OpenAiProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenAiProvider
impl Debug for OpenAiProvider
Source§impl LlmProvider for OpenAiProvider
impl LlmProvider for OpenAiProvider
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn complete_structured<'life0, 'async_trait>(
&'life0 self,
req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_structured<'life0, 'async_trait>(
&'life0 self,
req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Request a JSON response conforming to a caller-supplied schema.
Default impl returns an error. Providers that support structured
output (e.g. OpenAI-compatible) override this.
Source§fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream a completion token-by-token. Read more
Source§fn complete_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn complete_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Variant that accepts a partition between eager and deferred
tools. Providers that support native deferred loading (e.g.
Anthropic via
defer_loading: true + tool_reference content
blocks) override this. The default implementation concatenates
the two lists (dropping the hints) and calls complete() —
i.e., it ignores the partition and behaves identically to the
legacy interface. Read moreSource§fn complete_simple<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
_temperature: f32,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_simple<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
_temperature: f32,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Simple completion with a single user prompt. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAiProvider
impl !UnwindSafe for OpenAiProvider
impl Freeze for OpenAiProvider
impl Send for OpenAiProvider
impl Sync for OpenAiProvider
impl Unpin for OpenAiProvider
impl UnsafeUnpin for OpenAiProvider
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more