[Bug] 无法更改类型为OpenAI Compatible模型提供商源的ID
What happened / 发生了什么
此bug在v4.26.0-beta.3中也出现,不过当时没有深究
在v4.26.0-beta.8中,可视化编辑类型为 OpenAI Compatible的提供商源的ID
保存后编辑界面的ID处显示为更改的id,但是此时 供应商源 一栏中本应更改的提供商源在变更为新id后的一瞬间又变更为原id且状态变为 未选中 导致无法更改供应商源id
Reproduce / 如何复现?
- 打开AstrBot WebUI
- 点击侧边栏中的
模型提供商选项卡 - 在
对话类型中点击新增类型为OpenAI Compatible的提供商源或选择已有的类型为OpenAI Compatible的提供商源 - 在编辑界面更改
ID - 点击
保存配置或保存并获取模型选项 - bug复现
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
AstrBot v4.26.0-beta.8 手动部署(源码构建) Ubuntu24.04LTS
OS
Linux
Logs / 报错日志
恕本人无能,未能在Debug级别的日志输出下寻找到有关日志(或没有输出有关日志),望开发团队谅解
Are you willing to submit a PR? / 你愿意提交 PR 吗?
- [ ] Yes!
Code of Conduct
- [x] I have read and agree to abide by the project's Code of Conduct。
找到了,问题在这里:
class ProviderSourceRequest(OpenModel):
source_id: str | None = None
id: str | None = None
config: dict[str, Any] | None = None
def to_dashboard_config(self, *, fallback_id: str | None = None) -> dict[str, Any]:
config = dict(
self.config
or self.model_dump(exclude={"source_id", "config"}, exclude_none=True)
)
if fallback_id:
config["id"] = fallback_id
elif self.id and "id" not in config:
config["id"] = self.id
return config
逻辑是这样的: 后端拿到payload,把原先的old_id变成fallback_id,之后进入这个函数,可问题来了,fallback_id不为空,于是判断成立,直接把要准备传的id变成fallback_id了!于是就出现了无法更改提供源商的id的现象了!
找到了,问题在这里:
class ProviderSourceRequest(OpenModel): source_id: str | None = None id: str | None = None config: dict[str, Any] | None = None def to_dashboard_config(self, *, fallback_id: str | None = None) -> dict[str, Any]: config = dict( self.config or self.model_dump(exclude={"source_id", "config"}, exclude_none=True) ) if fallback_id: config["id"] = fallback_id elif self.id and "id" not in config: config["id"] = self.id return config逻辑是这样的: 后端拿到payload,把原先的old_id变成fallback_id,之后进入这个函数,可问题来了,fallback_id不为空,于是判断成立,直接把要准备传的id变成fallback_id了!于是就出现了无法更改提供源商的id的现象了!
好棒好棒,大佬牛逼~
找到了,问题在这里:
class ProviderSourceRequest(OpenModel): source_id: str | None = None id: str | None = None config: dict[str, Any] | None = None
def to_dashboard_config(self, *, fallback_id: str | None = None) -> dict[str, Any]: config = dict( self.config or self.model_dump(exclude={"source_id", "config"}, exclude_none=True) ) if fallback_id: config["id"] = fallback_id elif self.id and "id" not in config: config["id"] = self.id return config逻辑是这样的: 后端拿到payload,把原先的old_id变成fallback_id,之后进入这个函数,可问题来了,fallback_id不为空,于是判断成立,直接把要准备传的id变成fallback_id了!于是就出现了无法更改提供源商的id的现象了!
👍👍欢迎提交pr
抱歉哈,我暂时没有提交pr的计划