pub struct OpenAiProvider { /* private fields */ }Expand description
Built-in provider for the OpenAI Chat Completions API.
Also compatible with Azure OpenAI and any OpenAI-compatible endpoint.
Requires the openai feature flag.
§Example
use llm_agent_runtime::providers::OpenAiProvider;
let provider = OpenAiProvider::new("sk-...");
// For Azure or custom endpoints:
let custom = OpenAiProvider::with_base_url("sk-...", "https://my-endpoint/v1");Implementations§
Source§impl OpenAiProvider
impl OpenAiProvider
Trait Implementations§
Source§impl LlmProvider for OpenAiProvider
impl LlmProvider for OpenAiProvider
Source§fn complete_with_options<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
options: CompletionOptions<'life2>,
) -> Pin<Box<dyn Future<Output = Result<String, AgentRuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete_with_options<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
options: CompletionOptions<'life2>,
) -> Pin<Box<dyn Future<Output = Result<String, AgentRuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Complete with per-request options (max_tokens, temperature, timeout).
Honours options.max_tokens and options.temperature when set, falling
back to the API default when unset.
Source§fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
model: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentRuntimeError>> + 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,
prompt: &'life1 str,
model: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<String, AgentRuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send a prompt to the model and return the completion text. Read more
Source§fn stream_complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
model: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Result<String, AgentRuntimeError>>, AgentRuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream_complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
model: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Result<String, AgentRuntimeError>>, AgentRuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream the completion token-by-token. Read more
Auto Trait Implementations§
impl Freeze for OpenAiProvider
impl !RefUnwindSafe for OpenAiProvider
impl Send for OpenAiProvider
impl Sync for OpenAiProvider
impl Unpin for OpenAiProvider
impl UnsafeUnpin for OpenAiProvider
impl !UnwindSafe 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