pub struct OpenAiProvider { /* private fields */ }Expand description
OpenAI 兼容 API 的 LLM Provider 实现(v17 t02 起支持双协议)
Implementations§
Source§impl OpenAiProvider
impl OpenAiProvider
Sourcepub fn new(config: &LlmSection, protocol: OpenAiProtocol) -> Result<Self>
pub fn new(config: &LlmSection, protocol: OpenAiProtocol) -> Result<Self>
从配置创建 OpenAI Provider(v17 起按 provider 类型绑定协议)
优先使用 api_key 字段,其次从环境变量读取。支持自定义 base_url。
Trait Implementations§
Source§impl LlmProvider for OpenAiProvider
impl LlmProvider for OpenAiProvider
Source§async fn complete_with_budget(
&self,
messages: &[Message],
max_output_tokens: Option<u32>,
) -> Result<String>
async fn complete_with_budget( &self, messages: &[Message], max_output_tokens: Option<u32>, ) -> Result<String>
带输出预算的完整调用(评测裁判用):流式路径 + 显式预算 (推理型模型 reasoning 吞预算,见 trait 文档)
async fn complete_stream(&self, messages: &[Message]) -> Result<Vec<String>>
Source§fn call_count(&self) -> usize
fn call_count(&self) -> usize
返回已完成的 LLM 调用次数
async fn complete(&self, messages: &[Message]) -> Result<String>
Auto Trait Implementations§
impl !Freeze for OpenAiProvider
impl !RefUnwindSafe for OpenAiProvider
impl !UnwindSafe 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more