From 3523227a3817aa7f2f288b09b0430785f7f8fa09 Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Mon, 3 Aug 2026 16:20:34 +0800 Subject: [PATCH] update --- b/cntoai/sync_model_to_llm.dspy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/b/cntoai/sync_model_to_llm.dspy b/b/cntoai/sync_model_to_llm.dspy index 917f0cf..6602670 100644 --- a/b/cntoai/sync_model_to_llm.dspy +++ b/b/cntoai/sync_model_to_llm.dspy @@ -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)