feat(llm): agent模型下拉按org_id过滤
This commit is contained in:
parent
13769e5515
commit
1254ff8d96
@ -1,13 +1,18 @@
|
|||||||
# agent_model_options.dspy - 返回 active 模型列表(供 AgentIO 模型选择下拉)
|
# agent_model_options.dspy - 返回 active 模型列表(供 AgentIO 模型选择下拉)
|
||||||
# llm 表是 pipeline 库的通用配置,产线无关
|
# llm 表是 pipeline 库的通用配置,产线无关
|
||||||
|
# org_id 多租户隔离:非系统级机构只看到「本机构 + 系统级(org_id='0')」的模型
|
||||||
|
|
||||||
dbname = get_module_dbname('pipeline_core')
|
dbname = get_module_dbname('pipeline_core')
|
||||||
|
org_id = (await get_userorgid()) or ''
|
||||||
|
|
||||||
async with DBPools().sqlorContext(dbname) as sor:
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
recs = await sor.sqlExe(
|
sql = "SELECT id, name, provider, model_id, capabilities FROM llm WHERE status='active'"
|
||||||
"SELECT id, name, provider, model_id, capabilities FROM llm WHERE status='active' ORDER BY name",
|
params = {}
|
||||||
{}
|
if org_id and org_id != '0':
|
||||||
)
|
sql += " AND (org_id=${org}$ OR org_id='0')"
|
||||||
|
params['org'] = org_id
|
||||||
|
sql += " ORDER BY (org_id='0') ASC, name"
|
||||||
|
recs = await sor.sqlExe(sql, params)
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
for r in recs:
|
for r in recs:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user