Files
Aether/_deprecated_py_src/services/provider/behavior.py
fawney19 1d9c77522a 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)
2026-04-03 16:26:16 +08:00

61 lines
1.7 KiB
Python

"""Provider behavior 薄封装。
对外保持既有调用接口,内部统一委托给 core.api_format.capabilities 中的 provider registry。
"""
from __future__ import annotations
from dataclasses import dataclass
from src.core.api_format.capabilities import (
get_provider_behavior_variants,
register_provider_behavior_variant,
)
from src.core.provider_types import normalize_provider_type
from src.services.provider.envelope import ProviderEnvelope, get_provider_envelope
@dataclass(frozen=True, slots=True)
class ProviderBehavior:
provider_type: str
envelope: ProviderEnvelope | None
same_format_variant: str | None
cross_format_variant: str | None
def register_behavior_variant(
provider_type: str,
*,
same_format: bool = False,
cross_format: bool = False,
) -> None:
"""兼容入口:注册 provider 的格式变体标志,真实存储位于 core registry。"""
register_provider_behavior_variant(
provider_type,
same_format=same_format,
cross_format=cross_format,
)
def get_provider_behavior(
*,
provider_type: str | None,
endpoint_sig: str | None,
) -> ProviderBehavior:
pt = normalize_provider_type(provider_type)
envelope = get_provider_envelope(provider_type=pt, endpoint_sig=endpoint_sig)
same_format_variant, cross_format_variant = get_provider_behavior_variants(
provider_type=pt,
endpoint_sig=endpoint_sig or "",
)
return ProviderBehavior(
provider_type=pt,
envelope=envelope,
same_format_variant=same_format_variant,
cross_format_variant=cross_format_variant,
)
__all__ = ["ProviderBehavior", "get_provider_behavior", "register_behavior_variant"]