mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
feat(billing): 引入 model_id 精确计费查找路径,传播模型 ID 至用量事件与 report context
- UsageEventData 新增 model_id / global_model_id 字段,write.rs seed 结构体同步补充 - report_context 新增 model_id / global_model_id / global_model_name,各 payload 构建时从 candidate 传入 - event_enrichment 优先按 model_id 精确查找计费上下文,回退为按名称多轮查找(保留 NoRule 结果降级逻辑) - BillingReadRepository 新增 find_model_context_by_model_id,memory/sql 分别实现;SQL 查询重构支持按 provider_model_name 和 mappings 匹配并按优先级排序 - pricing.rs 修复:model_tiered_pricing 为空 tiers 时回退到 default_tiered_pricing - request_metadata 允许字段列表补充 model_id / global_model_id / global_model_name - admin usage 路由信息输出及脱敏字段列表同步新增三个 model 相关字段
This commit is contained in:
@@ -150,4 +150,14 @@ pub trait BillingReadRepository: Send + Sync {
|
||||
provider_api_key_id: Option<&str>,
|
||||
global_model_name: &str,
|
||||
) -> Result<Option<StoredBillingModelContext>, crate::DataLayerError>;
|
||||
|
||||
async fn find_model_context_by_model_id(
|
||||
&self,
|
||||
provider_id: &str,
|
||||
provider_api_key_id: Option<&str>,
|
||||
model_id: &str,
|
||||
) -> Result<Option<StoredBillingModelContext>, crate::DataLayerError> {
|
||||
let _ = (provider_id, provider_api_key_id, model_id);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,6 +500,18 @@ impl StoredRequestUsageAudit {
|
||||
.or_else(|| self.request_metadata_string("key_name"))
|
||||
}
|
||||
|
||||
pub fn routing_model_id(&self) -> Option<&str> {
|
||||
self.request_metadata_string("model_id")
|
||||
}
|
||||
|
||||
pub fn routing_global_model_id(&self) -> Option<&str> {
|
||||
self.request_metadata_string("global_model_id")
|
||||
}
|
||||
|
||||
pub fn routing_global_model_name(&self) -> Option<&str> {
|
||||
self.request_metadata_string("global_model_name")
|
||||
}
|
||||
|
||||
pub fn routing_planner_kind(&self) -> Option<&str> {
|
||||
self.planner_kind
|
||||
.as_deref()
|
||||
|
||||
Reference in New Issue
Block a user