- get_search_providerid.dspy: return {providerid, providerid_text}
- get_search_upappid.dspy: return {upappid, upappid_text}
- get_search_apiname.dspy: return {apiname, apiname_text}
- json/llm.json: add valueField/textField for providerid, upappid
- json/llm_api_map.json: add valueField/textField for apiname, query_apiname
This ensures filter form and add/edit form use the same data format.
34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
llmid = params_kw.get('llmid')
|
|
allow_empty = params_kw.get('allow_empty', '')
|
|
|
|
result = []
|
|
if allow_empty:
|
|
result = [{'apiname': '', 'apiname_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 apiname, name as apiname_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)
|