diff --git a/pipeline_service/gateway.py b/pipeline_service/gateway.py index f2675f5..491fbcb 100644 --- a/pipeline_service/gateway.py +++ b/pipeline_service/gateway.py @@ -83,15 +83,18 @@ class Gateway: db = DBPools() async with db.sqlorContext("pipeline") as sor: recs = await sor.sqlExe( - "SELECT s.current_project_id, s.default_llm_id, l.name as llm_name " - "FROM pipeline_agent_settings s " - "LEFT JOIN llm l ON l.id = s.default_llm_id AND l.status='active' " - "WHERE s.user_id=${u}$", + "SELECT current_project_id, default_llm_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": user_id}) if recs: ctx["pid"] = getattr(recs[0], "current_project_id", "") or "" ctx["default_llm_id"] = getattr(recs[0], "default_llm_id", "") or "" - ctx["default_llm_name"] = getattr(recs[0], "llm_name", "") or "" + # 单独查 llm.name(避免 JOIN 触发两表字段 collation 不一致) + if ctx["default_llm_id"]: + llm_recs = await sor.sqlExe( + "SELECT name FROM llm WHERE id=${id}$ AND status='active'", + {"id": ctx["default_llm_id"]}) + if llm_recs: + ctx["default_llm_name"] = getattr(llm_recs[0], "name", "") or "" if ctx["pid"]: proj = await sor.sqlExe( "SELECT name, pipeline_id FROM sd_projects WHERE id=${p}$",