This commit is contained in:
ping 2026-08-03 16:20:34 +08:00
parent 08cc6e012b
commit 3523227a38

View File

@ -170,7 +170,11 @@ async def sync_model_to_llm(ns={}):
async def upsert_llm(sor, item):
llm_data = build_llm_data(item)
exist_llm = await sor.R('llm', {'model': item.get('model')})
# 厂商 id 是 llm 表主键,优先按 id 更新,避免模型名称变化后重复插入主键
exist_llm = await sor.R('llm', {'id': llm_data.get('id')})
if not exist_llm:
# 兼容历史数据:相同 model 可能已使用其他本地主键
exist_llm = await sor.R('llm', {'model': item.get('model')})
if exist_llm:
llm_data['id'] = exist_llm[0].get('id')
await sor.U('llm', llm_data)