From cd054c7d224c95448e96211c659224334bf3099c Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 1 Sep 2026 13:59:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(rag):=20engine=5Fform.dspy=E6=8B=AC?= =?UTF-8?q?=E5=8F=B7=E5=B9=B3=E8=A1=A1,=E9=95=BFscript=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=8F=90=E4=B8=BA=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/engine_configs_list/engine_form.dspy | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wwwroot/engine_configs_list/engine_form.dspy b/wwwroot/engine_configs_list/engine_form.dspy index dd48c9e..e21ec76 100644 --- a/wwwroot/engine_configs_list/engine_form.dspy +++ b/wwwroot/engine_configs_list/engine_form.dspy @@ -19,6 +19,22 @@ def card(title, desc, prefix, cfg): shielded = (not cfg["model_id"]) or cfg["status"] != "active" state = "⛔ 已屏蔽" if shielded else "✅ 启用中" key_hint = "已配置(留空沿用)" if cfg["has_key"] else "未配置" + test_script = ("var p=this.parent.parent;" + "var m=bricks.getWidgetById('" + prefix + "_model',p).resultValue()||'';" + "var b=bricks.getWidgetById('" + prefix + "_base',p).resultValue()||'';" + "var k=bricks.getWidgetById('" + prefix + "_key',p).resultValue()||'';" + "fetch('./engine_test.dspy?_webbricks_=1&engine_type=" + prefix + + "&model_id='+encodeURIComponent(m)+'&api_base='+encodeURIComponent(b)+'&api_key='+encodeURIComponent(k))" + ".then(function(r){return r.json()}).then(function(d){" + "bricks.show_message({title:'" + title + " 测试',message:d.message||d.error||JSON.stringify(d)})})") + save_script = ("var p=this.parent.parent;" + "var m=bricks.getWidgetById('" + prefix + "_model',p).resultValue()||'';" + "var b=bricks.getWidgetById('" + prefix + "_base',p).resultValue()||'';" + "var k=bricks.getWidgetById('" + prefix + "_key',p).resultValue()||'';" + "fetch('./engine_save.dspy?_webbricks_=1&engine_type=" + prefix + + "&model_id='+encodeURIComponent(m)+'&api_base='+encodeURIComponent(b)+'&api_key='+encodeURIComponent(k))" + ".then(function(r){return r.json()}).then(function(d){" + "bricks.show_message({title:'保存',message:(d.error||('已保存:'+(d.shielded?'能力屏蔽':'已启用')))+'(刷新页面查看状态)'})})") return { "widgettype": "VBox", "options": {"width": "100%", "spacing": "12px", "bgcolor": "#f8f9fa", "padding": "16px", "css": "card"}, "subwidgets": [ @@ -33,8 +49,8 @@ def card(title, desc, prefix, cfg): {"widgettype": "Input", "id": prefix + "_key", "options": {"label": "API Key(" + key_hint + ")", "name": prefix + "_key", "type": "password", "cwidth": 24}} ]}, {"widgettype": "HBox", "options": {"spacing": "12px"}, "subwidgets": [ - {"widgettype": "Button", "options": {"label": "测试连通", "css": "outline", "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": "var p=this.parent.parent;var m=bricks.getWidgetById('" + prefix + "_model',p).resultValue()||'';var b=bricks.getWidgetById('" + prefix + "_base',p).resultValue()||'';var k=bricks.getWidgetById('" + prefix + "_key',p).resultValue()||'';fetch('./engine_test.dspy?_webbricks_=1&engine_type=" + prefix + "&model_id='+encodeURIComponent(m)+'&api_base='+encodeURIComponent(b)+'&api_key='+encodeURIComponent(k)).then(function(r){return r.json()}).then(function(d){bricks.show_message({title:'" + title + " 测试',message:d.message||d.error||JSON.stringify(d)})})"}]}, - {"widgettype": "Button", "options": {"label": "保存", "bgcolor": "#10b981", "color": "#fff", "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": "var p=this.parent.parent;var m=bricks.getWidgetById('" + prefix + "_model',p).resultValue()||'';var b=bricks.getWidgetById('" + prefix + "_base',p).resultValue()||'';var k=bricks.getWidgetById('" + prefix + "_key',p).resultValue()||'';fetch('./engine_save.dspy?_webbricks_=1&engine_type=" + prefix + "&model_id='+encodeURIComponent(m)+'&api_base='+encodeURIComponent(b)+'&api_key='+encodeURIComponent(k)).then(function(r){return r.json()}).then(function(d){bricks.show_message({title:'保存',message:(d.error||('已保存:'+(d.shielded?'能力屏蔽':'已启用')))+'(刷新页面查看状态)'})})"}]} + {"widgettype": "Button", "options": {"label": "测试连通", "css": "outline", "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": test_script}]}}, + {"widgettype": "Button", "options": {"label": "保存", "bgcolor": "#10b981", "color": "#fff", "binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": save_script}]}} ]} ] }