diff --git a/json/llm.json b/json/llm.json index 0a4e63e..538c227 100644 --- a/json/llm.json +++ b/json/llm.json @@ -3,6 +3,7 @@ "title": "大语言模型管理", "params": { "sortby": "created_at", + "logined_userorgid": "org_id", "browserfields": { "exclouded": ["id", "api_key"], "cwidth": {} diff --git a/models/llm.json b/models/llm.json index c4aee72..653ad5d 100644 --- a/models/llm.json +++ b/models/llm.json @@ -15,6 +15,7 @@ {"name": "api_key", "title": "API密钥", "type": "str", "length": 500}, {"name": "max_tokens", "title": "最大Token", "type": "int", "default": "8192"}, {"name": "status", "title": "状态", "type": "str", "length": 20, "default": "active"}, + {"name": "org_id", "title": "所属机构ID", "type": "str", "length": 32, "default": "0"}, {"name": "description", "title": "描述", "type": "text"}, {"name": "created_at", "title": "创建时间", "type": "timestamp"}, {"name": "updated_at", "title": "更新时间", "type": "timestamp"} diff --git a/models/pipelines.json b/models/pipelines.json index 893f0a7..572dd8e 100644 --- a/models/pipelines.json +++ b/models/pipelines.json @@ -76,6 +76,13 @@ "length": 500, "uitype": "text" }, + { + "name": "default_model", + "title": "缺省模型", + "type": "str", + "length": 100, + "uitype": "code" + }, { "name": "org_id", "title": "所属机构ID", @@ -134,6 +141,13 @@ "valuefield": "k", "textfield": "v", "cond": "parentid='pipeline_status'" + }, + { + "field": "default_model", + "table": "llm", + "valuefield": "name", + "textfield": "name", + "cond": "status='active'" } ] } \ No newline at end of file diff --git a/pipeline_core/agent_config.py b/pipeline_core/agent_config.py index 72776f4..432804d 100644 --- a/pipeline_core/agent_config.py +++ b/pipeline_core/agent_config.py @@ -360,21 +360,30 @@ async def load_agent_config(pipeline_id: str = None, project_id: str = None) -> except (json.JSONDecodeError, TypeError): pass - # 产线级配置 + # 产线级配置 + 产线缺省模型 if pipeline_id: recs = await sor.sqlExe( - "SELECT agent_config FROM pipelines WHERE id=${pid}$", + "SELECT agent_config, default_model FROM pipelines WHERE id=${pid}$", {"pid": pipeline_id}, ) if recs: - raw = getattr(recs[0], "agent_config", "") + raw = getattr(recs[0], "agent_config", "") or "" + default_model = getattr(recs[0], "default_model", "") or "" if raw: try: data = json.loads(raw) if isinstance(raw, str) else raw data["tools"] = _merge_tools(data.get("tools", []), SDLC_DEFAULT_TOOLS) + # 产线缺省模型:agent_config 未显式设 model_name 时用 default_model 兜底 + if not data.get("model_name") and default_model: + data["model_name"] = default_model return AgentConfig.from_dict(data) except (json.JSONDecodeError, TypeError): pass + elif default_model: + # agent_config 为空,仅产线设了缺省模型 + cfg = AgentConfig.from_dict(SDLC_DEFAULT_CONFIG.to_dict()) + cfg.model_name = default_model + return cfg except Exception: pass