pub struct Context<CTXEXT> {
pub ext: Arc<CTXEXT>,
pub cost_multiplier: Decimal,
pub ensemble_cache: Arc<DashMap<String, Shared<Receiver<Result<Option<(Ensemble, u64)>, ResponseError>>>>>,
pub ensemble_llm_cache: Arc<DashMap<String, Shared<Receiver<Result<Option<(EnsembleLlm, u64)>, ResponseError>>>>>,
}Expand description
Per-request context containing user-specific state and deduplication caches.
The context is generic over CTXEXT, allowing custom extensions for
different deployment scenarios (e.g., different BYOK providers).
§Caches
The caches deduplicate concurrent fetches for the same resource within a request. When multiple parts of a request need the same ensemble or ensemble LLM, only one fetch is performed and the result is shared.
Fields§
§ext: Arc<CTXEXT>Custom context extension (e.g., for BYOK keys).
cost_multiplier: DecimalMultiplier applied to costs for this request.
ensemble_cache: Arc<DashMap<String, Shared<Receiver<Result<Option<(Ensemble, u64)>, ResponseError>>>>>Cache for ensemble fetches, keyed by ensemble ID.
ensemble_llm_cache: Arc<DashMap<String, Shared<Receiver<Result<Option<(EnsembleLlm, u64)>, ResponseError>>>>>Cache for ensemble LLM fetches, keyed by ensemble LLM ID.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<CTXEXT> Freeze for Context<CTXEXT>
impl<CTXEXT> !RefUnwindSafe for Context<CTXEXT>
impl<CTXEXT> Send for Context<CTXEXT>
impl<CTXEXT> Sync for Context<CTXEXT>
impl<CTXEXT> Unpin for Context<CTXEXT>
impl<CTXEXT> !UnwindSafe for Context<CTXEXT>
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,
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