From 8a99624da3d0b7e07ae2c10e4a67be278bdfb676 Mon Sep 17 00:00:00 2001 From: Izayoi9 Date: Fri, 27 Mar 2026 02:30:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20removesuffix=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=20rstrip=20=E4=BF=AE=E5=A4=8D=20URL=20?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E8=AF=AF=E5=88=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前在 #6863 中我提交的修复使用了 rstrip() 来移除末尾的 /embeddings, 但 rstrip() 是字符集操作,会误删 URL 末尾属于该字符集的字符。 例如 siliconflow.cn 的末尾 n 会被误删,导致 URL 变成 siliconflow.c 改用 removesuffix() 可以正确处理这种情况,只在字符串以指定后缀结尾时才移除。 closes #7025 --- astrbot/core/provider/sources/openai_embedding_source.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/sources/openai_embedding_source.py b/astrbot/core/provider/sources/openai_embedding_source.py index 9bf127766f..ae531996ae 100644 --- a/astrbot/core/provider/sources/openai_embedding_source.py +++ b/astrbot/core/provider/sources/openai_embedding_source.py @@ -27,8 +27,8 @@ def __init__(self, provider_config: dict, provider_settings: dict) -> None: api_base = ( provider_config.get("embedding_api_base", "https://api.openai.com/v1") .strip() - .rstrip("/") - .rstrip("/embeddings") + .removesuffix("/") + .removesuffix("/embeddings") ) if api_base and not api_base.endswith("/v1") and not api_base.endswith("/v4"): # /v4 see #5699