From f264a7b3076d1e79008006c5a0c9273e63b7529a Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Tue, 7 Jul 2026 14:14:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20base=5Furl=20?= =?UTF-8?q?=E6=9C=AB=E5=B0=BE=E6=96=9C=E6=9D=A0,=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E4=BA=A7=E7=94=9F=E5=8F=8C=E6=96=9C=E6=9D=A0?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anthropic.rs 和 openai.rs 在构造时 trim_end_matches('/'),兼容如 https://opencode.ai/zen/go/v1/ 带末尾斜杠的 base_url。 --- src/providers/anthropic.rs | 3 +++ src/providers/openai.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/providers/anthropic.rs b/src/providers/anthropic.rs index d3ba937..0ee0823 100644 --- a/src/providers/anthropic.rs +++ b/src/providers/anthropic.rs @@ -159,6 +159,9 @@ impl AnthropicProvider { .build() .unwrap_or_else(|_| Client::new()); + // 兼容带末尾斜杠的 base_url,避免 format!("{}/v1/messages", base_url) 产生双斜杠 + let base_url = base_url.trim_end_matches('/').to_string(); + Self { client, name, diff --git a/src/providers/openai.rs b/src/providers/openai.rs index 9469b46..01d62ad 100644 --- a/src/providers/openai.rs +++ b/src/providers/openai.rs @@ -263,6 +263,10 @@ impl OpenAIProvider { .build() .unwrap_or_else(|_| Client::new()); + // 兼容带末尾斜杠的 base_url(如 https://opencode.ai/zen/go/v1/), + // 否则 format!("{}/chat/completions", base_url) 会产生双斜杠导致 404 + let base_url = base_url.trim_end_matches('/').to_string(); + Self { client, name,