What happened / 发生了什么
在使用 OpenAI Embedding Provider 时,如果 API Base URL 以 /embeddings 字符集中的字符结尾(如 siliconflow.cn 的 n),会被 rstrip() 误删导致 URL 错误。
例如:
- 输入:
https://api.siliconflow.cn
- 实际结果:
https://api.siliconflow.c/v1(n 被误删)
- 期望结果:
https://api.siliconflow.cn/v1
Reproduce / 如何复现?
- 添加一个 OpenAI Embedding 类型的提供商
- 设置 API Base URL 为
https://api.siliconflow.cn
- 保存并重启 AstrBot
- 查看日志,显示的 URL 为
https://api.siliconflow.c/v1(n 被误删)
AstrBot version, deployment method / AstrBot 版本、部署方式
v4.22.1 Docker
OS
Linux
Logs / 报错日志
[OpenAI Embedding] 硅基流动qwen3 8B Using API Base: https://api.siliconflow.c/v1
注意 URL 中的 siliconflow.c 应该是 siliconflow.cn,n 被 rstrip("/embeddings") 误删了。
原因分析
之前的 PR #6863 中使用了 .rstrip("/embeddings") 来移除末尾的 /embeddings 路径。
但 rstrip() 是字符集操作,会移除末尾所有在指定字符串中的字符,而不是移除子字符串。
# 错误用法
"siliconflow.cn".rstrip("/embeddings") # 结果: "siliconflow.c"(n 被删掉了)
# 正确用法
"siliconflow.cn".removesuffix("/embeddings") # 结果: "siliconflow.cn"(无变化)
Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct
What happened / 发生了什么
在使用 OpenAI Embedding Provider 时,如果 API Base URL 以
/embeddings字符集中的字符结尾(如siliconflow.cn的n),会被rstrip()误删导致 URL 错误。例如:
https://api.siliconflow.cnhttps://api.siliconflow.c/v1(n被误删)https://api.siliconflow.cn/v1Reproduce / 如何复现?
https://api.siliconflow.cnhttps://api.siliconflow.c/v1(n被误删)AstrBot version, deployment method / AstrBot 版本、部署方式
v4.22.1 Docker
OS
Linux
Logs / 报错日志
注意 URL 中的
siliconflow.c应该是siliconflow.cn,n被rstrip("/embeddings")误删了。原因分析
之前的 PR #6863 中使用了
.rstrip("/embeddings")来移除末尾的/embeddings路径。但
rstrip()是字符集操作,会移除末尾所有在指定字符串中的字符,而不是移除子字符串。Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct