#!/usr/bin/env python3 import json result = {'success': False, 'data': {'llms': [], 'catelogs': []}} try: dbname = get_module_dbname('llmage') user_orgid = await get_userorgid() async with DBPools().sqlorContext(dbname) as sor: # Get all active LLMs belonging to the 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 [])] # Get all catalogs (assuming catalogs are global or filtered similarly if needed) 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 [])] result['success'] = True except Exception as e: result['error'] = str(e) return json.dumps(result, ensure_ascii=False, default=str)