pub struct CostCalculatorAdapter { /* private fields */ }Expand description
Adapter that bridges any CostCalculator (ChatModel pricing
source) into the EmbeddingCostCalculator surface.
Embeddings only consume input tokens, so the adapter constructs
a synthetic Usage with input_tokens populated from the
embedder’s EmbeddingUsage and delegates to the wrapped
calculator. Operators with a single shared entelix_policy::CostMeter
pricing table use this to charge embedding calls from the same
source as model and tool calls — one pricing source, three cost
surfaces, no drift.
Implementations§
Source§impl CostCalculatorAdapter
impl CostCalculatorAdapter
Sourcepub const fn new(inner: Arc<dyn CostCalculator>) -> Self
pub const fn new(inner: Arc<dyn CostCalculator>) -> Self
Wrap the supplied calculator. The adapter forwards every
embed call as a synthetic Usage and lets the inner
calculator’s pricing table do the lookup.
Trait Implementations§
Source§impl EmbeddingCostCalculator for CostCalculatorAdapter
impl EmbeddingCostCalculator for CostCalculatorAdapter
Source§fn compute_cost<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
model: &'life1 str,
usage: &'life2 EmbeddingUsage,
ctx: &'life3 ExecutionContext,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn compute_cost<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
model: &'life1 str,
usage: &'life2 EmbeddingUsage,
ctx: &'life3 ExecutionContext,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Compute the cost of one embedder call given the request
context, the embedder model name (operator-supplied at
MeteredEmbedder construction), and the embedder’s
reported usage record.Auto Trait Implementations§
impl Freeze for CostCalculatorAdapter
impl !RefUnwindSafe for CostCalculatorAdapter
impl Send for CostCalculatorAdapter
impl Sync for CostCalculatorAdapter
impl Unpin for CostCalculatorAdapter
impl UnsafeUnpin for CostCalculatorAdapter
impl !UnwindSafe for CostCalculatorAdapter
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