pub struct CostEstimator { /* private fields */ }Expand description
Pre-flight cost estimation engine.
Thread-safe — all methods take &self and the pricing table is built once
on construction.
Implementations§
Source§impl CostEstimator
impl CostEstimator
Sourcepub fn estimate_tokens(text: &str) -> usize
pub fn estimate_tokens(text: &str) -> usize
Estimate the number of tokens in text using the ~4 chars/token rule.
Sourcepub fn estimate_output_tokens(input_tokens: usize, task_type: TaskType) -> usize
pub fn estimate_output_tokens(input_tokens: usize, task_type: TaskType) -> usize
Estimate the expected number of output tokens given the input count and the nature of the task.
Sourcepub fn estimate_cost(
&self,
prompt: &str,
model: &str,
task_type: TaskType,
budget: &BudgetConfig,
) -> CostEstimate
pub fn estimate_cost( &self, prompt: &str, model: &str, task_type: TaskType, budget: &BudgetConfig, ) -> CostEstimate
Estimate the cost of a single prompt/model/task combination.
Sourcepub fn batch_estimate(
&self,
prompts: &[&str],
model: &str,
task_type: TaskType,
) -> Vec<CostEstimate>
pub fn batch_estimate( &self, prompts: &[&str], model: &str, task_type: TaskType, ) -> Vec<CostEstimate>
Estimate costs for a batch of prompts with a shared model and task type.
Each prompt is estimated independently; no budget is enforced here since the caller typically aggregates totals and applies limits externally.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CostEstimator
impl RefUnwindSafe for CostEstimator
impl Send for CostEstimator
impl Sync for CostEstimator
impl Unpin for CostEstimator
impl UnsafeUnpin for CostEstimator
impl UnwindSafe for CostEstimator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request