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>, ) -> Result<Self>
Sourcepub fn with_search_engine(self, engine: Arc<dyn ToolSearchEngine>) -> Self
pub fn with_search_engine(self, engine: Arc<dyn ToolSearchEngine>) -> Self
Replace the search engine used to resolve ToolSearchTool queries.
Sourcepub fn with_max_search_rounds(self, n: usize) -> Self
pub fn with_max_search_rounds(self, n: usize) -> Self
Set the maximum number of ToolSearchTool round-trips per
complete_with_search / stream_with_search call.
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 ChatProvider for OpenAiProvider
impl ChatProvider 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 complete_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [SpecWithHint],
deferred_tools: &'life3 [SpecWithHint],
) -> 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 [SpecWithHint],
deferred_tools: &'life3 [SpecWithHint],
) -> 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 stream_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [SpecWithHint],
deferred_tools: &'life3 [SpecWithHint],
stream_tx: Option<StreamSender>,
cancel_token: Option<CancellationToken>,
) -> 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 stream_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [SpecWithHint],
deferred_tools: &'life3 [SpecWithHint],
stream_tx: Option<StreamSender>,
cancel_token: Option<CancellationToken>,
) -> 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,
Search-aware streaming: model sees eager tools +
ToolSearchTool;
deferred tools become available only after the model requests them. Read moreSource§fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
cancel_token: Option<CancellationToken>,
) -> 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>,
cancel_token: Option<CancellationToken>,
) -> 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 supports_deferred_tools(&self) -> bool
fn supports_deferred_tools(&self) -> bool
Whether this provider supports deferred tool loading via
tool_reference content blocks (Anthropic API feature). 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
Source§impl Clone for OpenAiProvider
impl Clone for OpenAiProvider
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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.