diff --git a/json/llm.json b/json/llm.json index 8e4365e..ab7dcb6 100644 --- a/json/llm.json +++ b/json/llm.json @@ -36,6 +36,14 @@ "dataurl":"{{entire_url('/pricing/get_all_pricing_programs.dspy')}}", "textField": "name", "valueField": "id" + }, + "providerid": { + "uitype": "code", + "dataurl": "{{entire_url('../api/get_organizations.dspy')}}" + }, + "upappid": { + "uitype": "code", + "dataurl": "{{entire_url('../api/get_upapps.dspy')}}" } } }, diff --git a/wwwroot/api/llm_list.dspy b/wwwroot/api/llm_list.dspy index a13b467..5225bc4 100644 --- a/wwwroot/api/llm_list.dspy +++ b/wwwroot/api/llm_list.dspy @@ -51,6 +51,44 @@ try: """ rows = await sor.sqlExe(data_sql, {**filterdic, 'limit': rows_per_page, 'offset': offset}) result['rows'] = [dict(r) for r in (rows or [])] + + # Build text mappings for providerid and upappid + if result['rows']: + provider_ids = list(set(r['providerid'] for r in result['rows'] if r.get('providerid'))) + upapp_ids = list(set(r['upappid'] for r in result['rows'] if r.get('upappid'))) + + # Query organization table for providerid mapping + provider_map = {} + if provider_ids: + try: + async with get_sor_context(request._run_ns, 'rbac') as rbac_sor: + orgs = await rbac_sor.sqlExe( + "select id, orgname from organization", {} + ) + if orgs: + provider_map = {str(r.id): r.orgname or '' for r in orgs} + except Exception as e: + debug(f'get organization mapping error: {e}') + + # Query upapp table for upappid mapping + upapp_map = {} + if upapp_ids: + try: + async with get_sor_context(request._run_ns, 'uapi') as uapi_sor: + apps = await uapi_sor.sqlExe( + "select id, name from upapp", {} + ) + if apps: + upapp_map = {str(r.id): r.name or '' for r in apps} + except Exception as e: + debug(f'get upapp mapping error: {e}') + + # Attach text fields to rows + for row in result['rows']: + if row.get('providerid'): + row['providerid_text'] = provider_map.get(str(row['providerid'])) + if row.get('upappid'): + row['upappid_text'] = upapp_map.get(str(row['upappid'])) result['total'] = total result['success'] = True