SuperAPI AI 工具集

switchyard-lib-core

编程与开发

查看项目

更新于 10-16 02:34

技能介绍

用途:该技能面向 Switchyard 库核心(switchyard/lib/)的开发与审查,覆盖 profile、请求/响应行为、后端、路由 YAML、统计遥测、指标与 CLI 启动器集成等改动。

主要能力与约定:Switchyard 采用 profile 驱动构建,类型化 profile 配置通过 build() 返回运行时,仅在需要现有 Python HTTP 端点契约时用 ProfileSwitchyard 包装。执行链保持 request-side -> LLMBackend -> response-side -> TranslationEngine。新增 profile 放在 switchyard/lib/profiles/;请求侧/响应侧行为优先做成 profile 局部组件(async process(ctx, request/response));新后端继承 switchyard/lib/roles.py 的 LLMBackend 并置于 switchyard/lib/backends/,声明 supported_request_types。OpenAI 兼容提供方(如 NVIDIA Inference Hub、OpenRouter)复用现有后端/配置,仅在协议确有差异时新增后端。路由 YAML 使用 switchyard/cli/route_bundle.py 与 switchyard/lib/route_table_builders.py。统计复用 StatsRequestProcessor、StatsResponseProcessor、StatsLlmBackend、StatsAccumulator,不另写采集器。会话亲和可配置 session_affinity: true、affinity_store: redis 等,需 switchyard[affinity-redis] 额外依赖。指标使用 PrometheusEmitter、outcome_metrics、upstream_error_log 等既有设施。

使用方式:编辑前配合 switchyard-codebase-exploration 建立影响图,编辑后用 switchyard-testing-ci 选择验证集;涉及启动器需求时参考 switchyard-coding-agent-launchers。

限制:不要重新引入工厂、配方、中间件包、请求/响应管道包装器或资源缓存;不要新增并行统计采集器;不要为仅指向 OpenAI 兼容端点而新增专用后端或翻译器;不要手算 token 成本,应使用内置估算器。改动 Rust 拥有的后端角色类、公共 API 导出、HTTP 端点或依赖前需先询问。资料未提供具体安装命令、收费与平台信息。