fix(llm_api_map_manage): 修正uitype规范+VScrollPanel滚动+llmid隐藏字段

- select→code, text→str, number→int 对齐bricks uitype规范
- 表单区域父容器改用VScrollPanel(height:500px)防止超出屏幕
- llmid改为uitype:hidden, 从params_kw.llmid获取值(从llm CRUD tool触发)
- 移除llmid的select下拉和label
This commit is contained in:
yumoqing 2026-05-21 16:11:40 +08:00
parent ca21d5cf25
commit f1498178cc
10 changed files with 230 additions and 86 deletions

12
llmage.egg-info/PKG-INFO Normal file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1 @@

View File

@ -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

View File

@ -0,0 +1 @@
llmage

Binary file not shown.

Binary file not shown.

56
migrate_catelog.py Normal file
View File

@ -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())

30
migrate_rel.py Normal file
View File

@ -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

View File

@ -13,6 +13,12 @@
"halign": "left" "halign": "left"
} }
}, },
{
"widgettype": "VScrollPanel",
"options": {
"height": "500px"
},
"subwidgets": [
{ {
"widgettype": "VBox", "widgettype": "VBox",
"options": { "options": {
@ -40,16 +46,13 @@
"fields": [ "fields": [
{ {
"name": "llmid", "name": "llmid",
"label": "选择模型", "uitype": "hidden",
"uitype": "select", "value": "{{params_kw.llmid}}"
"dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}",
"data_field": "llms",
"placeholder": "请选择模型"
}, },
{ {
"name": "llmcatelogid", "name": "llmcatelogid",
"label": "选择分类", "label": "选择分类",
"uitype": "select", "uitype": "code",
"dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}",
"data_field": "catelogs", "data_field": "catelogs",
"placeholder": "请选择分类" "placeholder": "请选择分类"
@ -57,7 +60,7 @@
{ {
"name": "apiname", "name": "apiname",
"label": "API接口", "label": "API接口",
"uitype": "select", "uitype": "code",
"dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}",
"data_field": "apis", "data_field": "apis",
"placeholder": "请选择API接口" "placeholder": "请选择API接口"
@ -65,19 +68,19 @@
{ {
"name": "query_apiname", "name": "query_apiname",
"label": "查询API", "label": "查询API",
"uitype": "text", "uitype": "str",
"placeholder": "异步查询API名多个用逗号分隔" "placeholder": "异步查询API名多个用逗号分隔"
}, },
{ {
"name": "query_period", "name": "query_period",
"label": "查询间隔(秒)", "label": "查询间隔(秒)",
"uitype": "number", "uitype": "int",
"placeholder": "默认30" "placeholder": "默认30"
}, },
{ {
"name": "ppid", "name": "ppid",
"label": "计费项目", "label": "计费项目",
"uitype": "select", "uitype": "code",
"dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}", "dataurl": "{{entire_url('./api/llm_api_map_options.dspy')}}",
"data_field": "ppids", "data_field": "ppids",
"placeholder": "请选择计费项目" "placeholder": "请选择计费项目"
@ -113,6 +116,8 @@
] ]
} }
] ]
}
]
}, },
{ {
"widgettype": "VBox", "widgettype": "VBox",