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

@ -14,101 +14,106 @@
} }
}, },
{ {
"widgettype": "VBox", "widgettype": "VScrollPanel",
"options": { "options": {
"width": "calc(100% - 40px)", "height": "500px"
"margin": "0 20px",
"padding": "16px",
"bgcolor": "#f5f5f5",
"spacing": 12
}, },
"subwidgets": [ "subwidgets": [
{ {
"widgettype": "Text", "widgettype": "VBox",
"options": { "options": {
"text": "添加新映射", "width": "calc(100% - 40px)",
"fontSize": "16px", "margin": "0 20px",
"fontWeight": "bold" "padding": "16px",
} "bgcolor": "#f5f5f5",
}, "spacing": 12
{
"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"
}
]
}, },
"binds": [ "subwidgets": [
{ {
"wid": "add_btn", "widgettype": "Text",
"event": "click",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {"archor": "cc", "width": "30%", "height": "20%"},
"options": { "options": {
"url": "{{entire_url('./api/llm_api_map_create.dspy')}}", "text": "添加新映射",
"params": { "fontSize": "16px",
"llmid": "$[add_form.llmid]$", "fontWeight": "bold"
"llmcatelogid": "$[add_form.llmcatelogid]$",
"apiname": "$[add_form.apiname]$",
"query_apiname": "$[add_form.query_apiname]$",
"query_period": "$[add_form.query_period]$",
"ppid": "$[add_form.ppid]$"
}
} }
},
{
"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]$"
}
}
}
]
} }
] ]
} }