mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
refactor: 拆分大型模块为 mixin/子模块结构
- cli_handler_base.py 拆分为 7 个 mixin (event/monitor/prefetch/request/sse_helpers/stream/sync) - usage/service.py 拆分为 6 个子模块 (types/active_requests/cache_analysis/lifecycle/pricing/query/recording) - models/database 拆分为独立模型文件 (auth/misc/model/provider/stats/usage/user) - DUMMY_THOUGHT_SIGNATURE 常量提升到 core/api_format/conversion/constants 统一管理 - task/service.py 内联导入提升为顶层导入 - 流处理函数签名移除冗余的 http_client 参数
This commit is contained in:
10
src/core/api_format/conversion/constants.py
Normal file
10
src/core/api_format/conversion/constants.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""格式转换层常量定义。
|
||||
|
||||
将跨层共享的常量集中在 core 层,避免 core -> services 的反向依赖。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# Thinking 签名验证的跳过标记
|
||||
# 当无法获取真实签名时,使用此值作为占位符
|
||||
DUMMY_THOUGHT_SIGNATURE = "skip_thought_signature_validator"
|
||||
@@ -379,14 +379,11 @@ class GeminiNormalizer(FormatNormalizer):
|
||||
isinstance(p, dict) and p.get("thought") is True for p in parts
|
||||
)
|
||||
if not has_thought:
|
||||
try:
|
||||
from src.services.provider.adapters.antigravity.constants import (
|
||||
DUMMY_THOUGHT_SIGNATURE,
|
||||
)
|
||||
from src.core.api_format.conversion.constants import (
|
||||
DUMMY_THOUGHT_SIGNATURE,
|
||||
)
|
||||
|
||||
dummy_sig = DUMMY_THOUGHT_SIGNATURE
|
||||
except Exception:
|
||||
dummy_sig = "skip_thought_signature_validator"
|
||||
dummy_sig = DUMMY_THOUGHT_SIGNATURE
|
||||
|
||||
dummy_part: dict[str, Any] = {
|
||||
"text": "Thinking...",
|
||||
@@ -1423,10 +1420,11 @@ class GeminiNormalizer(FormatNormalizer):
|
||||
|
||||
if signature is None and target_variant == "antigravity":
|
||||
model_str = str(model or "")
|
||||
from src.core.api_format.conversion.constants import (
|
||||
DUMMY_THOUGHT_SIGNATURE,
|
||||
)
|
||||
|
||||
try:
|
||||
from src.services.provider.adapters.antigravity.constants import (
|
||||
DUMMY_THOUGHT_SIGNATURE,
|
||||
)
|
||||
from src.services.provider.adapters.antigravity.signature_cache import (
|
||||
signature_cache,
|
||||
)
|
||||
@@ -1445,7 +1443,7 @@ class GeminiNormalizer(FormatNormalizer):
|
||||
except Exception:
|
||||
# Best-effort fallback: Gemini models can accept a dummy signature.
|
||||
if model_str.startswith("gemini-"):
|
||||
signature = "skip_thought_signature_validator"
|
||||
signature = DUMMY_THOUGHT_SIGNATURE
|
||||
|
||||
# For Antigravity, missing signature is likely to fail upstream validation.
|
||||
if target_variant == "antigravity" and not signature:
|
||||
@@ -1564,8 +1562,9 @@ class GeminiNormalizer(FormatNormalizer):
|
||||
payload_sig = None
|
||||
|
||||
signature: str | None = None
|
||||
from src.core.api_format.conversion.constants import DUMMY_THOUGHT_SIGNATURE
|
||||
|
||||
try:
|
||||
from src.services.provider.adapters.antigravity.constants import DUMMY_THOUGHT_SIGNATURE
|
||||
from src.services.provider.adapters.antigravity.signature_cache import signature_cache
|
||||
|
||||
cached_or_dummy = signature_cache.get_or_dummy(model, text_val)
|
||||
|
||||
Reference in New Issue
Block a user