pub struct OpenAiProvider { /* private fields */ }Expand description
An OpenAI-compatible HTTP provider. The composition layer supplies its endpoint, credentials, and headers from runtime configuration.
Implementations§
Source§impl OpenAiProvider
impl OpenAiProvider
Sourcepub fn new(
base_url: impl Into<String>,
api_key: impl Into<String>,
extra_headers: HashMap<String, String>,
) -> Self
pub fn new( base_url: impl Into<String>, api_key: impl Into<String>, extra_headers: HashMap<String, String>, ) -> Self
Construct a provider for the given endpoint and key.
Sourcepub fn with_retry_log(self, log: Arc<RetryLog>) -> Self
pub fn with_retry_log(self, log: Arc<RetryLog>) -> Self
BP-7: report every retry this provider makes into log, which the
caller drains after each completion (see RetryLog).
Trait Implementations§
Source§impl Provider for OpenAiProvider
impl Provider for OpenAiProvider
Source§fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
on_delta: &'life2 (dyn for<'a> Fn(&'a str) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<(ChatMessage, Usage)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
on_delta: &'life2 (dyn for<'a> Fn(&'a str) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<(ChatMessage, Usage)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run one completion.
on_delta is called with each text chunk as it
streams in. Returns the fully assembled assistant message and usage.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