mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
- 删除全部 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)
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from copy import deepcopy
|
|
from typing import Any
|
|
|
|
MODEL_TEST_DEBUG_KEY = "model_test_debug"
|
|
MODEL_TEST_DEBUG_ATTR = "_model_test_debug"
|
|
|
|
|
|
def normalize_model_test_debug_payload(debug_payload: Any) -> dict[str, Any] | None:
|
|
if not isinstance(debug_payload, dict):
|
|
return None
|
|
|
|
normalized: dict[str, Any] = {}
|
|
for key in (
|
|
"request_url",
|
|
"request_headers",
|
|
"request_body",
|
|
"response_headers",
|
|
"response_body",
|
|
):
|
|
value = debug_payload.get(key)
|
|
if value is None:
|
|
continue
|
|
normalized[key] = deepcopy(value)
|
|
|
|
return normalized or None
|
|
|
|
|
|
def set_candidate_model_test_debug(candidate: Any, debug_payload: Any) -> None:
|
|
normalized = normalize_model_test_debug_payload(debug_payload)
|
|
if normalized is None:
|
|
return
|
|
setattr(candidate, MODEL_TEST_DEBUG_ATTR, normalized)
|
|
|
|
|
|
def get_candidate_model_test_debug(candidate: Any) -> dict[str, Any] | None:
|
|
return normalize_model_test_debug_payload(getattr(candidate, MODEL_TEST_DEBUG_ATTR, None))
|
|
|
|
|
|
def merge_model_test_debug(
|
|
extra_data: dict[str, Any] | None,
|
|
debug_payload: Any,
|
|
) -> dict[str, Any] | None:
|
|
normalized = normalize_model_test_debug_payload(debug_payload)
|
|
if normalized is None:
|
|
return extra_data
|
|
|
|
merged = dict(extra_data or {})
|
|
merged[MODEL_TEST_DEBUG_KEY] = normalized
|
|
return merged
|
|
|
|
|
|
def get_model_test_debug_from_extra_data(extra_data: Any) -> dict[str, Any] | None:
|
|
if not isinstance(extra_data, dict):
|
|
return None
|
|
return normalize_model_test_debug_payload(extra_data.get(MODEL_TEST_DEBUG_KEY))
|