#!/usr/bin/env python3 import json result = {'success': False, 'data': {'llms': [], 'catelogs': [], 'apis': [], 'ppids': []}} try: dbname = get_module_dbname('llmage') user_orgid = await get_userorgid() async with DBPools().sqlorContext(dbname) as sor: # Active LLMs for user's organization today = await get_business_date(sor) llms_sql = """select id, name from llm where enabled_date <= ${today}$ and expired_date > ${today}$ and ownerid = ${ownerid}$ order by name""" llms = await sor.sqlExe(llms_sql, {'today': today, 'ownerid': user_orgid}) result['data']['llms'] = [{'id': r['id'], 'text': r['name']} for r in (llms or [])] # All catalogs catelogs = await sor.sqlExe("select id, name from llmcatelog order by name", {}) result['data']['catelogs'] = [{'id': r['id'], 'text': r['name']} for r in (catelogs or [])] # uapi list (for apiname selection) apis = await sor.sqlExe("select name, path from uapi order by name", {}) result['data']['apis'] = [{'id': r['name'], 'text': f"{r['name']} ({r['path']})"} for r in (apis or [])] # Pricing programs ppids = await sor.sqlExe("select id, name from pricing_program order by name", {}) result['data']['ppids'] = [{'id': r['id'], 'text': r['name']} for r in (ppids or [])] result['success'] = True except Exception as e: result['error'] = str(e) return json.dumps(result, ensure_ascii=False, default=str)