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:
fawney19
2026-04-03 16:26:16 +08:00
parent 8f26e1a31f
commit 1d9c77522a
868 changed files with 1735 additions and 2433 deletions

View File

@@ -0,0 +1,31 @@
"""
Collector definitions (config-file mode).
Goal:
- Developers define dimension collectors in code, grouped by api_format.
- Adding support for a new api_format should only require adding a new file here.
- No DB seeding required.
Each module should export:
- COLLECTORS: list[dict[str, Any]]
Each dict supports keys (aligned with DimensionCollector):
- api_format: "openai:chat" (canonical family:kind)
- task_type: "chat" | "cli" | "video" | "image" | "audio"
- dimension_name: string
- source_type: "request" | "response" | "metadata" | "computed"
- source_path: string | None
- value_type: "float" | "int" | "string"
- transform_expression: string | None
- default_value: string | None
- priority: int
- is_enabled: bool
"""
from __future__ import annotations
from typing import Any
# This package is discovered dynamically by `src.services.billing.presets`.
COLLECTORS: list[dict[str, Any]] = []

View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from typing import Any
# Anthropic / Claude messages
COLLECTORS: list[dict[str, Any]] = [
{
"api_format": "claude:chat",
"task_type": "chat",
"dimension_name": "input_tokens",
"source_type": "response",
"source_path": "usage.input_tokens",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
{
"api_format": "claude:chat",
"task_type": "chat",
"dimension_name": "output_tokens",
"source_type": "response",
"source_path": "usage.output_tokens",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
]

View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from typing import Any
# Gemini generateContent
COLLECTORS: list[dict[str, Any]] = [
{
"api_format": "gemini:chat",
"task_type": "chat",
"dimension_name": "input_tokens",
"source_type": "response",
"source_path": "usageMetadata.promptTokenCount",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
{
"api_format": "gemini:chat",
"task_type": "chat",
"dimension_name": "output_tokens",
"source_type": "response",
"source_path": "usageMetadata.candidatesTokenCount",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
]

View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from typing import Any
# OpenAI chat completions
COLLECTORS: list[dict[str, Any]] = [
{
"api_format": "openai:chat",
"task_type": "chat",
"dimension_name": "input_tokens",
"source_type": "response",
"source_path": "usage.prompt_tokens",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
{
"api_format": "openai:chat",
"task_type": "chat",
"dimension_name": "output_tokens",
"source_type": "response",
"source_path": "usage.completion_tokens",
"value_type": "int",
"priority": 10,
"is_enabled": True,
},
]

View File

@@ -0,0 +1,116 @@
from __future__ import annotations
from typing import Any
# Async video finalize flow: extra dims from metadata (base_dimensions already provided by caller).
#
# Note:
# - DimensionCollectorService has a "video -> base api_format fallback" that may query
# base api_format collectors when api_format is "openai:video"/"gemini:video" etc.
COLLECTORS: list[dict[str, Any]] = [
# Prefer size as "resolution key" (e.g. 1024x1792), fallback to resolution label (e.g. 720p/4k).
{
"api_format": "openai:chat",
"task_type": "video",
"dimension_name": "video_resolution_key",
"source_type": "metadata",
"source_path": "task.size",
"value_type": "string",
"priority": 10,
"is_enabled": True,
},
{
"api_format": "openai:chat",
"task_type": "video",
"dimension_name": "video_resolution_key",
"source_type": "metadata",
"source_path": "task.resolution",
"value_type": "string",
"priority": 0,
"is_enabled": True,
},
{
"api_format": "openai:chat",
"task_type": "video",
"dimension_name": "video_size_bytes",
"source_type": "metadata",
"source_path": "task.video_size_bytes",
"value_type": "int",
"priority": 0,
"is_enabled": True,
},
# 实际视频时长(秒),优先使用从 provider 响应中提取的实际时长
{
"api_format": "openai:chat",
"task_type": "video",
"dimension_name": "video_duration_seconds",
"source_type": "metadata",
"source_path": "task.video_duration_seconds",
"value_type": "float",
"priority": 10,
"is_enabled": True,
},
# 回退到请求的 duration_seconds如果没有实际时长
{
"api_format": "openai:chat",
"task_type": "video",
"dimension_name": "video_duration_seconds",
"source_type": "metadata",
"source_path": "task.duration_seconds",
"value_type": "int",
"priority": 0,
"is_enabled": True,
},
{
"api_format": "gemini:chat",
"task_type": "video",
"dimension_name": "video_resolution_key",
"source_type": "metadata",
"source_path": "task.size",
"value_type": "string",
"priority": 10,
"is_enabled": True,
},
{
"api_format": "gemini:chat",
"task_type": "video",
"dimension_name": "video_resolution_key",
"source_type": "metadata",
"source_path": "task.resolution",
"value_type": "string",
"priority": 0,
"is_enabled": True,
},
{
"api_format": "gemini:chat",
"task_type": "video",
"dimension_name": "video_size_bytes",
"source_type": "metadata",
"source_path": "task.video_size_bytes",
"value_type": "int",
"priority": 0,
"is_enabled": True,
},
# 实际视频时长(秒),优先使用从 provider 响应中提取的实际时长
{
"api_format": "gemini:chat",
"task_type": "video",
"dimension_name": "video_duration_seconds",
"source_type": "metadata",
"source_path": "task.video_duration_seconds",
"value_type": "float",
"priority": 10,
"is_enabled": True,
},
# 回退到请求的 duration_seconds如果没有实际时长
{
"api_format": "gemini:chat",
"task_type": "video",
"dimension_name": "video_duration_seconds",
"source_type": "metadata",
"source_path": "task.duration_seconds",
"value_type": "int",
"priority": 0,
"is_enabled": True,
},
]