pub struct OpenAIProvider { /* private fields */ }Expand description
OpenAI-compatible LLM provider
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.api_key("sk-...")
.model("gpt-4o");Implementations§
Source§impl OpenAIProvider
impl OpenAIProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OpenAI provider with default settings
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new();Sourcepub fn base_url(self, value: impl Into<String>) -> Self
pub fn base_url(self, value: impl Into<String>) -> Self
Set the base URL for the API endpoint (default: https://api.openai.com/v1)
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.base_url("https://api.custom.com/v1");Sourcepub fn api_key(self, value: impl Into<String>) -> Self
pub fn api_key(self, value: impl Into<String>) -> Self
Set the API key for authentication (default: empty string)
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.api_key("sk-...");Sourcepub fn model(self, value: impl Into<String>) -> Self
pub fn model(self, value: impl Into<String>) -> Self
Set the model name to use (default: gpt-4o)
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.model("gpt-4o-mini");Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Set maximum number of retries on failure (default: 3)
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.max_retries(5);Sourcepub fn retry_delay(self, delay_ms: u64) -> Self
pub fn retry_delay(self, delay_ms: u64) -> Self
Set delay between retries in milliseconds (default: 1000)
§Examples
use tiny_loop::llm::OpenAIProvider;
let provider = OpenAIProvider::new()
.retry_delay(2000);Trait Implementations§
Source§impl Default for OpenAIProvider
impl Default for OpenAIProvider
Source§impl LLMProvider for OpenAIProvider
impl LLMProvider for OpenAIProvider
Source§fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
messages: &'life1 [Message],
tools: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
messages: &'life1 [Message],
tools: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Call the LLM with messages and available tools, returning the assistant’s response
Auto Trait Implementations§
impl Freeze for OpenAIProvider
impl !RefUnwindSafe for OpenAIProvider
impl Send for OpenAIProvider
impl Sync for OpenAIProvider
impl Unpin 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