mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor: 移除 Python 后端源码,全面迁移至 Rust gateway 架构
- 删除全部 Python 源码 (src/) 及 Alembic 迁移脚本,归档至 _deprecated_py_src/ - 重构 Rust gateway ai_pipeline: 拆分 planner/finalize 模块,新增 contracts/adaptation 层 - 重组 handlers 模块为 admin/public/proxy/internal/shared 子模块结构 - 新增 executor 模块,引入 Rust 原生数据库迁移 (aether-data/migrations) - 简化 CI/Docker 构建流程,移除 base image 二级构建,统一为单一 app image - 移除 Python 相关基础设施文件 (entrypoint.sh, gunicorn_conf.py, Dockerfile.base)
This commit is contained in:
57
_deprecated_py_src/services/billing/__init__.py
Normal file
57
_deprecated_py_src/services/billing/__init__.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
计费模块
|
||||
|
||||
提供配置驱动的计费计算,支持不同厂商的差异化计费模式:
|
||||
- Claude: input + output + cache_creation + cache_read
|
||||
- OpenAI: input + output + cache_read (无缓存创建费用)
|
||||
- 豆包: input + output + cache_read + cache_storage (缓存按时计费)
|
||||
- 按次计费: per_request
|
||||
|
||||
使用方式:
|
||||
from src.services.billing import BillingCalculator, UsageMapper, StandardizedUsage
|
||||
|
||||
# 1. 将原始 usage 映射为标准格式
|
||||
usage = UsageMapper.map(raw_usage, api_format="openai:chat")
|
||||
|
||||
# 2. 使用计费计算器计算费用
|
||||
calculator = BillingCalculator(template="openai")
|
||||
result = calculator.calculate(usage, prices)
|
||||
|
||||
# 3. 获取费用明细
|
||||
print(result.total_cost)
|
||||
print(result.costs) # {"input": 0.01, "output": 0.02, ...}
|
||||
"""
|
||||
|
||||
from src.services.billing.calculator import BillingCalculator, calculate_request_cost
|
||||
from src.services.billing.models import (
|
||||
BillingDimension,
|
||||
BillingUnit,
|
||||
CostBreakdown,
|
||||
StandardizedUsage,
|
||||
)
|
||||
from src.services.billing.schema import BillingSnapshot, CostResult
|
||||
from src.services.billing.service import BillingService
|
||||
from src.services.billing.templates import BILLING_TEMPLATE_REGISTRY, BillingTemplates
|
||||
from src.services.billing.usage_mapper import UsageMapper, map_usage, map_usage_from_response
|
||||
|
||||
__all__ = [
|
||||
# 数据模型
|
||||
"BillingDimension",
|
||||
"BillingUnit",
|
||||
"CostBreakdown",
|
||||
"StandardizedUsage",
|
||||
# 模板
|
||||
"BillingTemplates",
|
||||
"BILLING_TEMPLATE_REGISTRY",
|
||||
# 计算器
|
||||
"BillingCalculator",
|
||||
"calculate_request_cost",
|
||||
# 统一入口
|
||||
"BillingService",
|
||||
"BillingSnapshot",
|
||||
"CostResult",
|
||||
# 映射器
|
||||
"UsageMapper",
|
||||
"map_usage",
|
||||
"map_usage_from_response",
|
||||
]
|
||||
Reference in New Issue
Block a user