feat(proxy): T-P4 路由端到端(M1:计费代理跑通)
- routes.py 主时序:auth(热缓存) -> 限流/并发槽 -> 413 -> 池条目解析 -> try_hold 预扣(字符/3 + min(max_tokens,4096) 宁可高估)-> 上游流式 tee -> usage 归一 -> compute -> settle(actual 回补) -> 流水;异常路径: UpstreamError 全额 void / UpstreamAborted 按已收 usage 结算 status=aborted - install_error_handlers:ProxyError 家族 -> §5.3 错误码 (401/402/403/413/429/502,401 带 WWW-Authenticate) - 管理面:students/topup/keys 签发/keys-revoke(X-Admin-Key 或 loopback) - SSE 同构:chunk 补齐 object/created/id/model(OpenAI SDK 兼容形状), usage chunk 按客户端要求过滤 - 修复:补回 T-P4 重写时丢失的 /proxy/v1/models - 测试 +8(非流式全程含 2550/1491 黄金账目/流式/402/401/413/502 void/ httpx 手写 OpenAI SDK 合规断言含 chunk 形状+usage 过滤+[DONE]),全量 362 passed
This commit is contained in:
@@ -209,6 +209,8 @@ try:
|
||||
_proxy_cfg = build_proxy_config(settings_store().to_dict())
|
||||
if _proxy_cfg.enabled:
|
||||
app.include_router(build_proxy_router(_proxy_cfg, get_pool()))
|
||||
from gateway.proxy.routes import install_error_handlers
|
||||
install_error_handlers(app)
|
||||
except Exception as _pe: # pragma: no cover - 代理层装配失败不拖垮主应用
|
||||
print(f"[gateway] 代理层未启用({_pe})")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user