pub trait AIProvider: Send + Sync {
// Required methods
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 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;
// Provided method
fn chat_completion<'life0, 'async_trait>(
&'life0 self,
_messages: Vec<Value>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
AI provider trait for content analysis and subtitle matching.
This trait defines the interface for AI services that can analyze video and subtitle content to determine optimal matches.
Required Methods§
Sourcefn 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,
Sourcefn 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,
Provided Methods§
Sourcefn chat_completion<'life0, 'async_trait>(
&'life0 self,
_messages: Vec<Value>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion<'life0, 'async_trait>(
&'life0 self,
_messages: Vec<Value>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a raw chat completion request to the provider.
This provides a provider-neutral entry point for callers (such as the translation engine) that need to issue prompts that do not fit the matching/verification request shape. Each provider implementation is responsible for handling authentication, retries, response size limits, and error sanitization, mirroring its specialized methods.
§Arguments
messages- OpenAI-compatible chat messages, e.g.[{"role":"system","content":"..."},{"role":"user","content":"..."}].
§Returns
The assistant message text from the first choice in the response.
§Errors
Returns crate::error::SubXError::AiService for HTTP, parsing, or
upstream provider errors. The default implementation returns
crate::error::SubXError::AiService indicating the provider does not
support raw chat completion; only providers that override this method
support translation prompts.