pub struct OpenAIClient { /* private fields */ }Expand description
OpenAI 客戶端實作 OpenAI 客戶端實作
Implementations§
Source§impl OpenAIClient
impl OpenAIClient
Sourcepub fn new(
api_key: String,
model: String,
temperature: f32,
retry_attempts: u32,
retry_delay_ms: u64,
) -> Self
pub fn new( api_key: String, model: String, temperature: f32, retry_attempts: u32, retry_delay_ms: u64, ) -> Self
建立新的 OpenAIClient (使用預設 base_url)
Sourcepub fn new_with_base_url(
api_key: String,
model: String,
temperature: f32,
retry_attempts: u32,
retry_delay_ms: u64,
base_url: String,
) -> Self
pub fn new_with_base_url( api_key: String, model: String, temperature: f32, retry_attempts: u32, retry_delay_ms: u64, base_url: String, ) -> Self
建立新的 OpenAIClient,支援自訂 base_url
Sourcepub fn from_config(config: &AIConfig) -> Result<Self>
pub fn from_config(config: &AIConfig) -> Result<Self>
從統一配置建立客戶端
Source§impl OpenAIClient
impl OpenAIClient
Sourcepub fn build_analysis_prompt(&self, request: &AnalysisRequest) -> String
pub fn build_analysis_prompt(&self, request: &AnalysisRequest) -> String
建立內容分析的 Prompt
Sourcepub fn parse_match_result(&self, response: &str) -> Result<MatchResult>
pub fn parse_match_result(&self, response: &str) -> Result<MatchResult>
從 AI 回應中解析匹配結果
Sourcepub fn build_verification_prompt(&self, request: &VerificationRequest) -> String
pub fn build_verification_prompt(&self, request: &VerificationRequest) -> String
建立匹配驗證的 Prompt
Sourcepub fn parse_confidence_score(&self, response: &str) -> Result<ConfidenceScore>
pub fn parse_confidence_score(&self, response: &str) -> Result<ConfidenceScore>
從 AI 回應中解析信心度分數
Trait Implementations§
Source§impl AIProvider for OpenAIClient
impl AIProvider for OpenAIClient
Source§fn analyze_content<'life0, 'async_trait>(
&'life0 self,
request: AnalysisRequest,
) -> Pin<Box<dyn Future<Output = Result<MatchResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn analyze_content<'life0, 'async_trait>(
&'life0 self,
request: AnalysisRequest,
) -> Pin<Box<dyn Future<Output = Result<MatchResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
分析多媒體檔案和字幕檔案的匹配結果
Source§fn verify_match<'life0, 'async_trait>(
&'life0 self,
verification: VerificationRequest,
) -> Pin<Box<dyn Future<Output = Result<ConfidenceScore>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_match<'life0, 'async_trait>(
&'life0 self,
verification: VerificationRequest,
) -> Pin<Box<dyn Future<Output = Result<ConfidenceScore>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
驗證檔案匹配的信心度
Auto Trait Implementations§
impl Freeze for OpenAIClient
impl !RefUnwindSafe for OpenAIClient
impl Send for OpenAIClient
impl Sync for OpenAIClient
impl Unpin for OpenAIClient
impl !UnwindSafe 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
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.