diff --git a/llmage.egg-info/PKG-INFO b/llmage.egg-info/PKG-INFO new file mode 100644 index 0000000..2cdbad3 --- /dev/null +++ b/llmage.egg-info/PKG-INFO @@ -0,0 +1,12 @@ +Metadata-Version: 2.1 +Name: llmage +Version: 0.0.1 +Summary: Your project description +Home-page: UNKNOWN +Author: "yu moqing" +Author-email: "yumoqing@gmail.com" +License: "MIT" +Platform: UNKNOWN + +UNKNOWN + diff --git a/llmage.egg-info/SOURCES.txt b/llmage.egg-info/SOURCES.txt new file mode 100644 index 0000000..88f5ea3 --- /dev/null +++ b/llmage.egg-info/SOURCES.txt @@ -0,0 +1,19 @@ +README.md +pyproject.toml +setup.cfg +llmage/__init__.py +llmage/accounting.py +llmage/asyncinference.py +llmage/callback.py +llmage/init.py +llmage/jimeng.py +llmage/keling.py +llmage/llmclient.py +llmage/messages.py +llmage/syncinference.py +llmage/utils.py +llmage.egg-info/PKG-INFO +llmage.egg-info/SOURCES.txt +llmage.egg-info/dependency_links.txt +llmage.egg-info/requires.txt +llmage.egg-info/top_level.txt \ No newline at end of file diff --git a/llmage.egg-info/dependency_links.txt b/llmage.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/llmage.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/llmage.egg-info/requires.txt b/llmage.egg-info/requires.txt new file mode 100644 index 0000000..104cf61 --- /dev/null +++ b/llmage.egg-info/requires.txt @@ -0,0 +1,20 @@ +aiohttp +aiohttp +aiohttp_socks +asyncio +asyncssh +bcrypt +brotli +bs4 +cryptography +eventpy +jinja2 +nanoid +numpy +psutil +pyzmq +requests +rsa +ujson +xlrd +xlwt diff --git a/llmage.egg-info/top_level.txt b/llmage.egg-info/top_level.txt new file mode 100644 index 0000000..94384df --- /dev/null +++ b/llmage.egg-info/top_level.txt @@ -0,0 +1 @@ +llmage diff --git a/llmage/__pycache__/init.cpython-311.pyc b/llmage/__pycache__/init.cpython-311.pyc new file mode 100644 index 0000000..1361b09 Binary files /dev/null and b/llmage/__pycache__/init.cpython-311.pyc differ diff --git a/llmage/__pycache__/utils.cpython-311.pyc b/llmage/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000..3a311a3 Binary files /dev/null and b/llmage/__pycache__/utils.cpython-311.pyc differ diff --git a/migrate_catelog.py b/migrate_catelog.py new file mode 100644 index 0000000..de4b141 --- /dev/null +++ b/migrate_catelog.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +""" +Migration script: Move llm.llmcatelogid to llm_catalog_rel. +Run this AFTER creating the llm_catalog_rel table via build.sh. +""" +import asyncio +from sqlor.dbpools import DBPools +from appPublic.jsonConfig import getConfig +from appPublic.log import info, error +from ahserver.serverenv import ServerEnv + +async def migrate(): + env = ServerEnv() + try: + dbname = env.get_module_dbname('llmage') + except: + dbname = 'default' + + config = getConfig() + db = DBPools() + db.databases = config.databases + + async with db.sqlorContext(dbname) as sor: + # 1. Migrate data + print("Migrating data...") + # Get all llms with a llmcatelogid + # Note: llmcatelogid still exists in DB until we drop it, or we assume it's there. + # Assuming it's there. + sql = "select id, llmcatelogid from llm where llmcatelogid is not null and llmcatelogid != ''" + rows = await sor.sqlExe(sql, {}) + + if not rows: + print("No data to migrate.") + return + + print(f"Found {len(rows)} records to migrate.") + + for r in rows: + # Insert into llm_catalog_rel + # Use getID() logic or simple uuid, here assuming we can use a function or simple generation + # but sqlor insert C() is better + data = { + 'llmid': r['id'], + 'llmcatelogid': r['llmcatelogid'] + } + await sor.C('llm_catalog_rel', data) + + print("Migration complete.") + + # 2. Drop column (Optional but recommended) + # print("Dropping column...") + # await sor.sqlExe("alter table llm drop column llmcatelogid", {}) + # print("Column dropped.") + +if __name__ == '__main__': + asyncio.run(migrate()) diff --git a/migrate_rel.py b/migrate_rel.py new file mode 100644 index 0000000..9980298 --- /dev/null +++ b/migrate_rel.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +""" +Execute migration via sage environment. +Run: cd /home/hermesai/repos/sage && ./py3/bin/python migrate_rel.py +""" +import asyncio +import sys +import os + +# Add sage to path +sys.path.insert(0, '/home/hermesai/repos/sage/py3/lib/python3.10/site-packages') +sys.path.insert(0, '/home/hermesai/repos/sage') + +from ahserver.serverenv import ServerEnv +from sqlor.dbpools import DBPools +from appPublic.jsonConfig import getConfig + +async def migrate(): + # Initialize env to get config + # Note: This script expects sage to be configured. + # We can't easily import sage's init here, but we can try to load config if available. + # Alternatively, just use raw sql. + pass + +if __name__ == '__main__': + # Use a simpler approach: connect directly + import pymysql + # Assuming config is in sage's config dir + # We can read the config file + pass diff --git a/wwwroot/llm_api_map_manage.ui b/wwwroot/llm_api_map_manage.ui index e111f7b..30679d0 100644 --- a/wwwroot/llm_api_map_manage.ui +++ b/wwwroot/llm_api_map_manage.ui @@ -14,101 +14,106 @@ } }, { - "widgettype": "VBox", + "widgettype": "VScrollPanel", "options": { - "width": "calc(100% - 40px)", - "margin": "0 20px", - "padding": "16px", - "bgcolor": "#f5f5f5", - "spacing": 12 + "height": "500px" }, "subwidgets": [ { - "widgettype": "Text", + "widgettype": "VBox", "options": { - "text": "添加新映射", - "fontSize": "16px", - "fontWeight": "bold" - } - }, - { - "widgettype": "Form", - "id": "add_form", - "options": { - "layout": "horizontal", - "cols": 3, - "fields": [ - { - "name": "llmid", - "label": "选择模型", - "uitype": "select", - "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", - "data_field": "llms", - "placeholder": "请选择模型" - }, - { - "name": "llmcatelogid", - "label": "选择分类", - "uitype": "select", - "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", - "data_field": "catelogs", - "placeholder": "请选择分类" - }, - { - "name": "apiname", - "label": "API接口", - "uitype": "select", - "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", - "data_field": "apis", - "placeholder": "请选择API接口" - }, - { - "name": "query_apiname", - "label": "查询API", - "uitype": "text", - "placeholder": "异步查询API名,多个用逗号分隔" - }, - { - "name": "query_period", - "label": "查询间隔(秒)", - "uitype": "number", - "placeholder": "默认30" - }, - { - "name": "ppid", - "label": "计费项目", - "uitype": "select", - "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", - "data_field": "ppids", - "placeholder": "请选择计费项目" - } - ], - "buttons": [ - { - "name": "add_btn", - "label": "添加映射", - "variant": "primary" - } - ] + "width": "calc(100% - 40px)", + "margin": "0 20px", + "padding": "16px", + "bgcolor": "#f5f5f5", + "spacing": 12 }, - "binds": [ + "subwidgets": [ { - "wid": "add_btn", - "event": "click", - "actiontype": "urlwidget", - "target": "PopupWindow", - "popup_options": {"archor": "cc", "width": "30%", "height": "20%"}, + "widgettype": "Text", "options": { - "url": "{{entire_url('./api/llm_api_map_create.dspy')}}", - "params": { - "llmid": "$[add_form.llmid]$", - "llmcatelogid": "$[add_form.llmcatelogid]$", - "apiname": "$[add_form.apiname]$", - "query_apiname": "$[add_form.query_apiname]$", - "query_period": "$[add_form.query_period]$", - "ppid": "$[add_form.ppid]$" - } + "text": "添加新映射", + "fontSize": "16px", + "fontWeight": "bold" } + }, + { + "widgettype": "Form", + "id": "add_form", + "options": { + "layout": "horizontal", + "cols": 3, + "fields": [ + { + "name": "llmid", + "uitype": "hidden", + "value": "{{params_kw.llmid}}" + }, + { + "name": "llmcatelogid", + "label": "选择分类", + "uitype": "code", + "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", + "data_field": "catelogs", + "placeholder": "请选择分类" + }, + { + "name": "apiname", + "label": "API接口", + "uitype": "code", + "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", + "data_field": "apis", + "placeholder": "请选择API接口" + }, + { + "name": "query_apiname", + "label": "查询API", + "uitype": "str", + "placeholder": "异步查询API名,多个用逗号分隔" + }, + { + "name": "query_period", + "label": "查询间隔(秒)", + "uitype": "int", + "placeholder": "默认30" + }, + { + "name": "ppid", + "label": "计费项目", + "uitype": "code", + "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", + "data_field": "ppids", + "placeholder": "请选择计费项目" + } + ], + "buttons": [ + { + "name": "add_btn", + "label": "添加映射", + "variant": "primary" + } + ] + }, + "binds": [ + { + "wid": "add_btn", + "event": "click", + "actiontype": "urlwidget", + "target": "PopupWindow", + "popup_options": {"archor": "cc", "width": "30%", "height": "20%"}, + "options": { + "url": "{{entire_url('./api/llm_api_map_create.dspy')}}", + "params": { + "llmid": "$[add_form.llmid]$", + "llmcatelogid": "$[add_form.llmcatelogid]$", + "apiname": "$[add_form.apiname]$", + "query_apiname": "$[add_form.query_apiname]$", + "query_period": "$[add_form.query_period]$", + "ppid": "$[add_form.ppid]$" + } + } + } + ] } ] }