Files
Aether/crates/aether-billing/src/lib.rs
AAEE86 335e440cc5 fix(usage): 统一使用记录与仪表盘的缓存命中率计算口径
- 新增归一化总输入上下文计算逻辑,按 provider 区分 OpenAI/Gemini 与 Claude 的 cache token 语义
- 将管理端使用聚合、用户使用记录、仪表盘缓存统计、缓存亲和性分析统一为 token 级缓存命中率
- 修正 total_input_context 字段,避免 cache_read 在部分 provider 上被重复计入分母
- 同步更新相关 Rust 单元测试与网关集成测试断言
- 调整前端 dashboard mock 中 cache_hit_rate 的单位为百分比
2026-04-12 00:57:40 +08:00

33 lines
1.2 KiB
Rust

mod default_rule;
mod event_enrichment;
mod formula_engine;
mod models;
mod precision;
mod pricing;
mod schema;
mod service;
mod token_normalization;
pub use aether_usage_runtime::{
map_usage, map_usage_from_response, StandardizedUsage, UsageMapper,
};
pub use default_rule::{normalize_task_type, DefaultBillingRuleGenerator, VirtualBillingRule};
pub use event_enrichment::{enrich_usage_event_with_billing, BillingModelContextLookup};
pub use formula_engine::{
extract_variable_names, BillingIncompleteError, ExpressionEvaluationError, FormulaEngine,
FormulaEvaluationResult, FormulaEvaluationStatus, UnsafeExpressionError,
};
pub use models::{BillingDimension, BillingUnit, CostBreakdown};
pub use precision::{
quantize_cost, quantize_display, quantize_value, BILLING_DISPLAY_PRECISION,
BILLING_STORAGE_PRECISION,
};
pub use pricing::{BillingComputation, BillingModelPricingSnapshot, BillingUsageInput};
pub use schema::{
BillingSnapshot, BillingSnapshotStatus, CostResult, BILLING_SNAPSHOT_SCHEMA_VERSION,
};
pub use service::BillingService;
pub use token_normalization::{
normalize_input_tokens_for_billing, normalize_total_input_context_for_cache_hit_rate,
};