- 新增 get_search_apiname.dspy: 根据llmid查upappid, 从uapi获取API列表 - apiname: code类型下拉选择(必选) - query_apiname: code类型下拉选择(可选, 含'不指定'选项) - 更新 json/llm_api_map.json CRUD定义 alters - 更新 llm_api_map_manage.ui 表单字段 - 重新生成 wwwroot/llm_api_map/index.ui - 注册 load_path.py RBAC权限
34 lines
1015 B
Plaintext
34 lines
1015 B
Plaintext
llmid = params_kw.get('llmid')
|
|
allow_empty = params_kw.get('allow_empty', '')
|
|
|
|
result = []
|
|
if allow_empty:
|
|
result = [{'value': '', 'text': '不指定'}]
|
|
|
|
try:
|
|
if not llmid:
|
|
return json.dumps(result, ensure_ascii=False)
|
|
|
|
# Get model's upappid from llmage db
|
|
dbname = get_module_dbname('llmage')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
llm_recs = await sor.sqlExe(
|
|
"select upappid from llm where id = ${llmid}$",
|
|
{'llmid': llmid}
|
|
)
|
|
if not llm_recs or not llm_recs[0].get('upappid'):
|
|
return json.dumps(result, ensure_ascii=False)
|
|
upappid = llm_recs[0].upappid
|
|
|
|
# Query uapi table from uapi module's db
|
|
async with get_sor_context(request._run_ns, 'uapi') as sor:
|
|
apis = await sor.sqlExe(
|
|
"select name as value, name as text from uapi where upappid = ${upappid}$ order by name",
|
|
{'upappid': upappid}
|
|
)
|
|
return json.dumps(result + list(apis), ensure_ascii=False)
|
|
except Exception as e:
|
|
debug(f'get_search_apiname error: {e}')
|
|
|
|
return json.dumps(result, ensure_ascii=False)
|