llmage/wwwroot/llmusage_usages_display.dspy
yumoqing 6890af7638 fix: 清理所有 dspy 文件的 import 语句
删除已在 ahserver/ServerEnv 预加载的模块:
  json, datetime, getID, debug, curDateString, timestampstr,
  get_sor_context, time, DictObject, partial, FileStorage, os

删除模块内部 import:
  from llmage.utils import get_llmusage_by_id, read_ioinfo_content

同步将 get_llmusage_by_id, read_ioinfo_content 加入 load_llmage() 导出,
dspy 中通过 ServerEnv 全局调用。
2026-06-30 17:38:37 +08:00

52 lines
1.4 KiB
Plaintext

usage_id = params_kw.get('id')
if not usage_id:
return {"widgettype": "Message", "options": {"message": "缺少 id 参数", "type": "error"}}
record = await get_llmusage_by_id(usage_id)
if not record:
return {"widgettype": "Message", "options": {"message": "未找到记录", "type": "error"}}
llmid = record.get('llmid', '')
usages_raw = record.get('usages', '')
try:
usages_obj = json.loads(usages_raw) if isinstance(usages_raw, str) else usages_raw
except (json.JSONDecodeError, TypeError):
usages_obj = usages_raw
usages_text = json.dumps(usages_obj, ensure_ascii=False, indent=2) if usages_obj else "无使用信息"
return {
"widgettype": "VScrollPanel",
"options": {
"width": "100%",
"height": "100%"
},
"subwidgets": [
{
"widgettype": "VBox",
"options": {
"width": "100%",
"padding": "16px",
"spacing": 12
},
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"text": f"Model: {llmid}"
}
},
{
"widgettype": "Text",
"options": {
"text": usages_text,
"css": "padding: 0 5px; white-space: pre-wrap; word-break: break-all;"
}
}
]
}
]
}