feat: 新增「中转站」provider(任意 Anthropic 兼容端点 + 自动获取模型)#4
Open
chimeraHHH wants to merge 1 commit into
Open
Conversation
新增 relay provider:填 base_url + token 即可接任意 Anthropic 兼容中转站, 并自动拉取该站可用模型铺进 Science 选择器。与 deepseek/qwen 不同——中转站 原生认 claude-*,故【透传不重映射】。 - proxy: relay provider(透传 + 模型贴合 + 双鉴权头 x-api-key+Bearer + /v1/models 回源直拉归一化);出站统一 User-Agent,绕过部分中转站 WAF 对 默认 Python-urllib 的 403。 - config.rs: ProviderCfg 加 base_url + base_url_for。 - lib.rs: relay 接入 ensure_proxy/get_config/set_config;新命令 fetch_relay_models。 - proc.rs: http_get_body(经本地回环代理取模型列表,Rust 侧免 TLS)。 - 前端: 中转站选项 + base_url 输入 + 获取模型 + 模型列表。 - 测试: 7 个 relay 单测。run_all.sh 全绿;cargo test 51/51。 deepseek/qwen 行为零变化(新分叉都以 PROV.get(...) 特性开关进入)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
CSSwitch 目前把上游写死成
deepseek(原生透传)/qwen(翻译)两个 provider。本 PR 新增relay(中转站):只给base_url+token即可接任意 Anthropic 兼容中转站,并自动发现该站可用模型铺进 Science 选择器。做了什么
relayprovider(proxy/csswitch_proxy.py):原生 Anthropic 透传,不重映射模型(中转站原生认claude-*);/v1/models回源直拉并归一化成 Science 认的格式,让选择器自动铺满中转站真实模型;双鉴权头(x-api-key+Authorization: Bearer)兼容各家;出站统一User-Agent(绕过部分中转站 WAF 对默认Python-urllib的 403);把 Science 发的裸 id(如标题 agent 的claude-haiku-4-5)贴合到中转站真实 id(claude-haiku-4-5-20251001)。config.rs):ProviderCfg加base_url+base_url_for。lib.rs):relay接入ensure_proxy/get_config/set_config;新命令fetch_relay_models(经本地回环代理回源拉模型,Rust 侧免 TLS)。proc.rs):http_get_body。base_url输入 + 「获取模型」按钮 + 模型列表展示。兼容性
deepseek/qwen行为零变化(新分叉都以PROV.get(...)特性开关进入,默认路径不动)。验证
test/run_all.sh全绿;proxy 单测 18/18(含 7 个 relay);cargo test51/51;cargo build通过。/v1/models归一化、非流式、流式、裸 id 贴合、入站 OAuth 剥离均通过。🤖 Generated with Claude Code