pub struct OpenAIAdapter { /* private fields */ }Expand description
OpenAI adapter for GPT models.
Implementations§
Source§impl OpenAIAdapter
impl OpenAIAdapter
Sourcepub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
Create a new OpenAI adapter.
§Arguments
api_key-OpenAIAPI keymodel- Model to use (e.g., “gpt-4o”, “gpt-4o-mini”)
Sourcepub const fn with_temperature(self, temperature: f32) -> Self
pub const fn with_temperature(self, temperature: f32) -> Self
Set the temperature for generation.
Sourcepub const fn with_max_tokens(self, max_tokens: u32) -> Self
pub const fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum tokens for generation.
Trait Implementations§
Source§impl LLMAdapter for OpenAIAdapter
impl LLMAdapter for OpenAIAdapter
Source§fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [LLMMessage],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [LLMMessage],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generate a completion from messages. Read more
Source§fn generate_stream(
&self,
messages: &[LLMMessage],
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LLMError>> + Send + '_>>
fn generate_stream( &self, messages: &[LLMMessage], ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LLMError>> + Send + '_>>
Generate a streaming completion. Read more
Auto Trait Implementations§
impl Freeze for OpenAIAdapter
impl !RefUnwindSafe for OpenAIAdapter
impl Send for OpenAIAdapter
impl Sync for OpenAIAdapter
impl Unpin for OpenAIAdapter
impl UnsafeUnpin for OpenAIAdapter
impl !UnwindSafe for OpenAIAdapter
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