pub struct OpenAiClient { /* private fields */ }Implementations§
Source§impl OpenAiClient
impl OpenAiClient
pub fn new( api_key: String, model: String, base_url: Option<String>, ) -> OpenAiClient
pub fn new_with_config( api_key: String, model: String, base_url: Option<String>, config: LlmClientConfig, ) -> OpenAiClient
Sourcepub fn with_model(&self, model: impl Into<String>) -> OpenAiClient
pub fn with_model(&self, model: impl Into<String>) -> OpenAiClient
使用不同模型的变体。共享底层 HTTP 连接池,零额外成本。
类似 Claude Code 的 opus/sonnet/haiku — 同一 client,不同 model。
Trait Implementations§
Source§impl LlmClient for OpenAiClient
impl LlmClient for OpenAiClient
fn chat<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
reasoning: Option<&'life3 ReasoningConfig>,
response_format: Option<&'life4 ResponseFormat>,
) -> Pin<Box<dyn Future<Output = Result<Value, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
OpenAiClient: 'async_trait,
fn chat_stream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
reasoning: Option<&'life3 ReasoningConfig>,
response_format: Option<&'life4 ResponseFormat>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, AgentError>> + Send>>, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
OpenAiClient: 'async_trait,
fn capabilities(&self) -> LlmCapabilities
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
The model name used by this client (e.g. “claude-sonnet”, “gpt-4o”).
Default: “unknown”.
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAiClient
impl !UnwindSafe for OpenAiClient
impl Freeze for OpenAiClient
impl Send for OpenAiClient
impl Sync for OpenAiClient
impl Unpin for OpenAiClient
impl UnsafeUnpin for OpenAiClient
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