feat(llm): agent模型下拉返回个人选择selected标记
This commit is contained in:
parent
ae7c55db48
commit
f842d2e70f
@ -1,8 +1,10 @@
|
||||
# agent_model_options.dspy - 返回 active 模型列表(供 AgentIO 模型选择下拉)
|
||||
# llm 表是 pipeline 库的通用配置,产线无关
|
||||
# org_id 多租户隔离:非系统级机构只看到本机构的模型(不含系统级兜底)
|
||||
# 返回每项带 selected 标记,标识个人之前选择的默认模型(default_llm_id)
|
||||
|
||||
dbname = get_module_dbname('pipeline_core')
|
||||
uid = await get_user()
|
||||
org_id = (await get_userorgid()) or ''
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
@ -14,6 +16,14 @@ async with DBPools().sqlorContext(dbname) as sor:
|
||||
sql += " ORDER BY name"
|
||||
recs = await sor.sqlExe(sql, params)
|
||||
|
||||
# 个人之前选择的默认模型
|
||||
current_llm_id = ''
|
||||
if uid:
|
||||
_s = await sor.sqlExe(
|
||||
"SELECT default_llm_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
if _s:
|
||||
current_llm_id = getattr(_s[0], 'default_llm_id', '') or ''
|
||||
|
||||
rows = []
|
||||
for r in recs:
|
||||
rows.append({
|
||||
@ -22,6 +32,7 @@ for r in recs:
|
||||
'provider': r.provider,
|
||||
'model_id': r.model_id,
|
||||
'capabilities': r.capabilities or 'text',
|
||||
'selected': r.id == current_llm_id,
|
||||
})
|
||||
|
||||
return rows
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user