pub trait InferenceProviderAdapter: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn tokens_from_headers(&self, headers: &HeaderMap) -> Option<u64>;
fn tokens_from_body(&self, body: &[u8]) -> Option<u64>;
fn estimate_request_tokens(
&self,
body: &[u8],
method: TokenEstimation,
) -> u64;
fn extract_model(&self, headers: &HeaderMap, body: &[u8]) -> Option<String>;
}Expand description
Trait for provider-specific token extraction and estimation
Required Methods§
Sourcefn tokens_from_headers(&self, headers: &HeaderMap) -> Option<u64>
fn tokens_from_headers(&self, headers: &HeaderMap) -> Option<u64>
Extract token count from response headers (primary method)
Sourcefn tokens_from_body(&self, body: &[u8]) -> Option<u64>
fn tokens_from_body(&self, body: &[u8]) -> Option<u64>
Extract token count from response body (fallback method)
Sourcefn estimate_request_tokens(&self, body: &[u8], method: TokenEstimation) -> u64
fn estimate_request_tokens(&self, body: &[u8], method: TokenEstimation) -> u64
Estimate tokens from request body using the specified method