fix: 优化同步上游模型的写回载荷,克隆并保留远端返回的所有非敏感 credentials,避免丢失 compact_model_mapping 等其它配置
This commit is contained in:
@@ -1391,8 +1391,12 @@ def sync_website_accounts_upstream_models(
|
||||
continue
|
||||
|
||||
# 1. 先安全修复 base_url (不依赖同步模型结果)
|
||||
# 在 remote_acc.get("credentials") 基础上进行修改,保留其他非敏感 credentials (例如 compact_model_mapping)
|
||||
current_creds = dict(remote_acc.get("credentials") or {})
|
||||
current_creds["base_url"] = upstream_base_url
|
||||
|
||||
try:
|
||||
c.update_account(aid, {"credentials": {"base_url": upstream_base_url}})
|
||||
c.update_account(aid, {"credentials": current_creds})
|
||||
except Exception as e:
|
||||
items.append(SyncUpstreamModelsItem(
|
||||
account_id=aid,
|
||||
@@ -1421,11 +1425,10 @@ def sync_website_accounts_upstream_models(
|
||||
))
|
||||
continue
|
||||
|
||||
# 3. 模型同步成功后,写回 base_url 和 model_mapping
|
||||
c.update_account(aid, {"credentials": {
|
||||
"base_url": upstream_base_url,
|
||||
"model_mapping": {m: m for m in valid_models}
|
||||
}})
|
||||
# 3. 模型同步成功后,在 current_creds 基础上替换 model_mapping 并写回
|
||||
updated_creds = dict(current_creds)
|
||||
updated_creds["model_mapping"] = {m: m for m in valid_models}
|
||||
c.update_account(aid, {"credentials": updated_creds})
|
||||
|
||||
items.append(SyncUpstreamModelsItem(
|
||||
account_id=aid,
|
||||
|
||||
Reference in New Issue
Block a user