Files
projectAIpopular/gateway/proxy/__init__.py
tzt b109576707 feat(proxy): T-P0 代理层骨架(包结构/DDL/门控挂载/单进程校验)
- gateway/proxy/ 十文件:config(ProxyConfig:元->毫元加载期换算 D-P1、差异化售价、
  桶/峰谷/限流/semcache 配置)/ errors(8 类 HTTP 语义异常)/ ledger(四表两索引 DDL,
  WAL,ReviewQueue 连接纪律)/ auth·pricing·normalizer·semcache·upstream(§6 签名占位)
  / routes(/proxy/v1/models OpenAI 形状)/ __init__(build_proxy_router 组装点)
- settings DEFAULTS 增 proxy 段(enabled 默认 False,D-P7)
- api.py 首次 include_router(enabled 门控 + 装配失败不拖垮主应用)
- serve.py workers>1 拒绝启动(D-P9:WEB_CONCURRENCY/UVICORN_WORKERS 校验)
- 测试 +4(门控 404/DDL 幂等/毫元换算/池模型列表),全量 322 passed
2026-09-05 08:35:31 +08:00

18 lines
633 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""校园 AI 代理层(T-P0…T-P8):/proxy/v1/* 学生面 + /proxy/admin/* 管理面。
组装唯一入口:build_proxy_router(cfg, pool) -> APIRouter
由 gateway.api 在 proxy.enabled 时 includeD-P7:关闭时不注册任何路由)。
"""
from __future__ import annotations
from fastapi import APIRouter
from gateway.proxy.config import ProxyConfig, build_proxy_config # noqa: F401
__all__ = ["build_proxy_router", "build_proxy_config", "ProxyConfig"]
def build_proxy_router(cfg: ProxyConfig, pool) -> APIRouter:
from gateway.proxy.routes import build_proxy_router as _build
return _build(cfg, pool)