mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
fix(opencodezen): UA 升到 1.19.4 并补回 x-opencode-session-id
- 上游按客户端指纹判定免费层资格:CLI 1.18.29(4 个 x-opencode-* 头) 稳定 429;CLI 1.19.4(5 个头,含 session-id)200 且任务真实完成。 - 适配器的 UA 与头集合必须**同步**升级:只改 UA 声称的版本、不发对应头, 指纹反而更不一致,实测重新落回 429。 - 头形状按官方 CLI 抓包校正;`x-opencode-session-id` 与 `x-opencode-session` 同值,此前被误删。 - live 测试新增 `gatewayBinary()`:优先 `MODELROUTER_BIN`,其次 `/usr/local/bin/modelrouter`,回退改名前的 `/usr/local/bin/llmsproxy`。 注:本提交是改名/插件整改之外的独立修复,先于 v3.0.0 收口。
This commit is contained in:
@ -14,10 +14,10 @@ import (
|
||||
)
|
||||
|
||||
// 真上游 e2e:用适配器产出的头 + body 直打 opencode /inference/v1。
|
||||
// 需要真实凭据(从生产配置解密),故用 LLMSPROXY_LIVE_ZEN=1 显式开启。
|
||||
// 需要真实凭据(从生产配置解密),故用 MODELROUTER_LIVE_ZEN=1 显式开启。
|
||||
func TestOpencodeZenLiveE2E(t *testing.T) {
|
||||
if os.Getenv("LLMSPROXY_LIVE_ZEN") != "1" {
|
||||
t.Skip("设 LLMSPROXY_LIVE_ZEN=1 开启真上游 e2e")
|
||||
if os.Getenv("MODELROUTER_LIVE_ZEN") != "1" {
|
||||
t.Skip("设 MODELROUTER_LIVE_ZEN=1 开启真上游 e2e")
|
||||
}
|
||||
src, err := bundledAdapters.ReadFile("adapters/opencodezen.lua")
|
||||
if err != nil {
|
||||
@ -30,8 +30,8 @@ func TestOpencodeZenLiveE2E(t *testing.T) {
|
||||
}
|
||||
|
||||
// 取生产凭据(解密)
|
||||
out, err := exec.Command("/usr/local/bin/llmsproxy", "-show-secrets",
|
||||
"-config", "/etc/llmsproxy/config.yaml").Output()
|
||||
out, err := exec.Command(gatewayBinary(), "-show-secrets",
|
||||
"-config", "/etc/modelrouter/config.yaml").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -131,8 +131,8 @@ func TestOpencodeZenLiveE2E(t *testing.T) {
|
||||
// 经适配器完整转换链:上游 SSE → transform_stream_chunk → 统一格式。
|
||||
// 上一条判据直接读原始 SSE,只证明"上游放行";这条证明"适配器能解析"。
|
||||
func TestOpencodeZenLiveStreamThroughAdapter(t *testing.T) {
|
||||
if os.Getenv("LLMSPROXY_LIVE_ZEN") != "1" {
|
||||
t.Skip("设 LLMSPROXY_LIVE_ZEN=1 开启")
|
||||
if os.Getenv("MODELROUTER_LIVE_ZEN") != "1" {
|
||||
t.Skip("设 MODELROUTER_LIVE_ZEN=1 开启")
|
||||
}
|
||||
src, err := bundledAdapters.ReadFile("adapters/opencodezen.lua")
|
||||
if err != nil {
|
||||
@ -143,8 +143,8 @@ func TestOpencodeZenLiveStreamThroughAdapter(t *testing.T) {
|
||||
if err := vm.LoadAdapterSource("opencodezen", string(src)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out, _ := exec.Command("/usr/local/bin/llmsproxy", "-show-secrets",
|
||||
"-config", "/etc/llmsproxy/config.yaml").Output()
|
||||
out, _ := exec.Command(gatewayBinary(), "-show-secrets",
|
||||
"-config", "/etc/modelrouter/config.yaml").Output()
|
||||
apiKey := ""
|
||||
for _, l := range strings.Split(string(out), "\n") {
|
||||
if strings.HasPrefix(l, "source localzen") {
|
||||
@ -211,3 +211,17 @@ func TestOpencodeZenLiveStreamThroughAdapter(t *testing.T) {
|
||||
}
|
||||
t.Logf("✓ 完整链:%d 个 chunk,内容=%q", n, strings.TrimSpace(joined))
|
||||
}
|
||||
|
||||
// gatewayBinary 定位本机网关二进制。改名后默认是 /usr/local/bin/modelrouter;
|
||||
// 仍兼容改名前的 /usr/local/bin/llmsproxy,避免测试脚本要跟着运维机器改。
|
||||
func gatewayBinary() string {
|
||||
if v := os.Getenv("MODELROUTER_BIN"); v != "" {
|
||||
return v
|
||||
}
|
||||
for _, p := range []string{"/usr/local/bin/modelrouter", "/usr/local/bin/llmsproxy"} {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return "/usr/local/bin/modelrouter"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user