pub struct ModelCapabilitiesCache { /* private fields */ }Expand description
Thread-safe cache for learned model capabilities.
Capabilities are discovered dynamically and cached for future use. The cache persists for the lifetime of the application.
Implementations§
Source§impl ModelCapabilitiesCache
impl ModelCapabilitiesCache
Sourcepub fn get(&self, provider: &str, model_id: &str) -> ModelCapabilities
pub fn get(&self, provider: &str, model_id: &str) -> ModelCapabilities
Get capabilities for a model, using cache or falling back to heuristics
Sourcepub fn learn_from_error(
&self,
provider: &str,
model_id: &str,
error_message: &str,
) -> Option<ModelCapabilities>
pub fn learn_from_error( &self, provider: &str, model_id: &str, error_message: &str, ) -> Option<ModelCapabilities>
Learn model capabilities from a context_length_exceeded error message.
Parses error messages like:
- “maximum context length is 16385 tokens”
- “your messages resulted in 17063 tokens”
Returns the learned capabilities if parsing succeeded.
Sourcepub fn store_from_api(&self, caps: ModelCapabilities)
pub fn store_from_api(&self, caps: ModelCapabilities)
Store capabilities discovered from API
Sourcepub fn store_user_override(
&self,
provider: &str,
model_id: &str,
context_length: usize,
)
pub fn store_user_override( &self, provider: &str, model_id: &str, context_length: usize, )
Store user-configured override
Trait Implementations§
Source§impl Clone for ModelCapabilitiesCache
impl Clone for ModelCapabilitiesCache
Source§fn clone(&self) -> ModelCapabilitiesCache
fn clone(&self) -> ModelCapabilitiesCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelCapabilitiesCache
impl Debug for ModelCapabilitiesCache
Source§impl Default for ModelCapabilitiesCache
impl Default for ModelCapabilitiesCache
Source§fn default() -> ModelCapabilitiesCache
fn default() -> ModelCapabilitiesCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ModelCapabilitiesCache
impl RefUnwindSafe for ModelCapabilitiesCache
impl Send for ModelCapabilitiesCache
impl Sync for ModelCapabilitiesCache
impl Unpin for ModelCapabilitiesCache
impl UnwindSafe for ModelCapabilitiesCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].