pipeline-llm/wwwroot/api/online_check_popup.dspy

65 lines
3.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# online_check_popup.dspy — 模型上线检查弹窗(2026-09-07 用户定夺)
# 选择一个模型 → 点击上线检查 → 内部助手按模型配置后的测试过程处理:
# test_model_call 真实调用(完整治理链)→ check_model_accounting 记账检查
# (created 等 60~120 秒复查)→ platform_llm_status 复核状态 → 给出最终结论。
import json as _json
import random
uid = await get_user()
if not uid:
return _json.dumps({
"widgettype": "PopupWindow",
"options": {"title": "提示", "cwidth": 30, "cheight": 8, "auto_open": True},
"subwidgets": [{"widgettype": "Text", "options": {"text": "请先登录", "padding": "20px"}}]
}, ensure_ascii=False)
session_id = 'llmchk' + str(random.randint(100000, 999999))
chat_url = entire_url('/pipeline_core/api/agent_chat.dspy') + '?session_id=' + session_id + '&pipeline_id=platform_general'
models_url = entire_url('/pipeline-llm/api/get_llm_online_check_models.dspy')
# 上线检查:读模型下拉(UiCode.resultValue = 模型名),下达标准检查指令
check_script = (
"var io=bricks.getWidgetById('llm_chk_io',bricks.app);if(!io||!io.inputw)return;"
"var sel=bricks.getWidgetById('llm_chk_model',bricks.app);"
"var m=sel&&sel.resultValue?String(sel.resultValue()||'').trim():'';"
"if(!m){new bricks.Message({title:'缺少输入',message:'请先选择要检查的模型'});return;}"
"var p='请对模型「'+m+'」执行上线检查,按模型配置后的测试过程处理:"
"1) test_model_call 真实调用测试(生成类模型缺业务参数时先问我,不要编造);"
"2) check_model_accounting 用返回的 task_ref 检查记账(created 则等 60~120 秒复查一次);"
"3) platform_llm_status 复核模型/定价/供应商状态;"
"4) 最后明确告诉我检查结果:通过 / 不通过 + 各环节明细 + 遗留事项,不要粉饰。';"
"io.inputw.textw.setValue(p);io.inputw.input_finished();")
resp = {
"widgettype": "PopupWindow",
"id": "llm_online_chk_pw",
"options": {"title": "✅ 模型上线检查(内部助手)", "width": "85%", "height": "85%", "auto_open": True},
"subwidgets": [{
"widgettype": "VBox",
"options": {"css": "filler", "width": "100%", "height": "100%", "padding": "12px", "gap": "8px"},
"subwidgets": [
{"widgettype": "Text", "options": {
"text": "选择模型后点击「上线检查」:内部助手执行真实调用测试(完整治理链)→ 记账检查(独立复算金额)→ 状态复核,最后给出通过/不通过结论。",
"cfontsize": 0.9, "color": "#64748b", "halign": "left"}},
{"widgettype": "HBox",
"options": {"gap": "8px", "alignItems": "center"},
"subwidgets": [
{"widgettype": "Text", "options": {"text": "模型:", "cfontsize": 0.95, "halign": "left"}},
{"widgettype": "UiCode", "id": "llm_chk_model",
"options": {"name": "llm_chk_model", "dataurl": models_url,
"valueField": "value", "textField": "text",
"nullable": True, "cwidth": 30}},
{"widgettype": "Button", "id": "llm_chk_start",
"options": {"label": "上线检查", "css": "small"},
"binds": [{"wid": "self", "event": "click", "actiontype": "script",
"target": "self", "script": check_script}]}]},
{"widgettype": "AgentIO", "id": "llm_chk_io",
"options": {"css": "filler", "url": chat_url,
"model_dataurl": entire_url('/pipeline_core/api/agent_model_options.dspy') + '?session_id=' + session_id + '&pipeline_id=platform_general',
"model_cwidth": 14,
"placeholder": "也可以直接对内部助手说话,例如:对模型 xxx 做上线检查"}}
]}]
}
return _json.dumps(resp, ensure_ascii=False)