Skip to content

Commit af6f9cf

Browse files
authored
fix: 使用 removesuffix 替代 rstrip 修复 URL 字符误删问题 (#7026)
之前在 #6863 中我提交的修复使用了 rstrip() 来移除末尾的 /embeddings, 但 rstrip() 是字符集操作,会误删 URL 末尾属于该字符集的字符。 例如 siliconflow.cn 的末尾 n 会被误删,导致 URL 变成 siliconflow.c 改用 removesuffix() 可以正确处理这种情况,只在字符串以指定后缀结尾时才移除。 closes #7025
1 parent 8986d05 commit af6f9cf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

astrbot/core/provider/sources/openai_embedding_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def __init__(self, provider_config: dict, provider_settings: dict) -> None:
2727
api_base = (
2828
provider_config.get("embedding_api_base", "https://api.openai.com/v1")
2929
.strip()
30-
.rstrip("/")
31-
.rstrip("/embeddings")
30+
.removesuffix("/")
31+
.removesuffix("/embeddings")
3232
)
3333
if api_base and not api_base.endswith("/v1") and not api_base.endswith("/v4"):
3434
# /v4 see #5699

0 commit comments

Comments
 (0)