feat: apiname/query_apiname改为从uapi动态选择
- 新增 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权限
This commit is contained in:
parent
d4e455ba9a
commit
a1c3eb4b25
@ -5,6 +5,14 @@
|
||||
"browserfields": {
|
||||
"exclouded": ["id", "llmid"],
|
||||
"alters": {
|
||||
"apiname": {
|
||||
"uitype": "code",
|
||||
"dataurl": "{{entire_url('../api/get_search_apiname.dspy')}}"
|
||||
},
|
||||
"query_apiname": {
|
||||
"uitype": "code",
|
||||
"dataurl": "{{entire_url('../api/get_search_apiname.dspy?allow_empty=1')}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editexclouded": ["id", "llmid"]
|
||||
|
||||
@ -90,6 +90,7 @@ PATHS_LOGINED = [
|
||||
f"/{MOD}/api/get_catelogs.dspy",
|
||||
f"/{MOD}/api/get_organizations.dspy",
|
||||
f"/{MOD}/api/get_ppids.dspy",
|
||||
f"/{MOD}/api/get_search_apiname.dspy",
|
||||
f"/{MOD}/api/get_search_providerid.dspy",
|
||||
f"/{MOD}/api/get_search_upappid.dspy",
|
||||
f"/{MOD}/api/get_upapps.dspy",
|
||||
|
||||
33
wwwroot/api/get_search_apiname.dspy
Normal file
33
wwwroot/api/get_search_apiname.dspy
Normal file
@ -0,0 +1,33 @@
|
||||
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)
|
||||
@ -60,14 +60,15 @@
|
||||
"name": "apiname",
|
||||
"label": "API接口",
|
||||
"uitype": "code",
|
||||
"dataurl": "{{entire_url('./api/get_apis.dspy')}}",
|
||||
"dataurl": "{{entire_url('./api/get_search_apiname.dspy')}}",
|
||||
"placeholder": "请选择API接口"
|
||||
},
|
||||
{
|
||||
"name": "query_apiname",
|
||||
"label": "查询API",
|
||||
"uitype": "str",
|
||||
"placeholder": "异步查询API名,多个用逗号分隔"
|
||||
"uitype": "code",
|
||||
"dataurl": "{{entire_url('./api/get_search_apiname.dspy?allow_empty=1')}}",
|
||||
"placeholder": "不指定或选择查询API"
|
||||
},
|
||||
{
|
||||
"name": "query_period",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user