diff --git a/wwwroot/agent_input.js b/wwwroot/agent_input.js new file mode 100644 index 0000000..4672922 --- /dev/null +++ b/wwwroot/agent_input.js @@ -0,0 +1,117 @@ +// AgentInput — 集成模型选择的输入控件 +// options: { model_dataurl, placeholder, url(提交图标), ...TextFiles 原有属性 } +// event: inputed → { prompt, add_files, model_id } + +bricks.AgentInput = class extends bricks.VBox { + constructor(opts) { + opts.height = 'auto'; + opts.width = '100%'; + super(opts); + + // file upload + this.inputfilew = new bricks.UiFile({name: 'add_file'}); + this.filesbar = new bricks.DynamicColumn({col_cwidth: 10}); + this.add_files = []; + this.inputfilew.bind('changed', this.file_added.bind(this)); + + // text input + this.textw = new bricks.UiText({ + name: 'prompt', + placeholder: opts.placeholder || '输入你的需求...' + }); + + // model selector (UiCode dropdown) + this.model_selector = new bricks.Form({ + name: 'model_selector', + cols: 1, + cwidth: opts.model_cwidth || 14, + fields: [{ + name: 'model_id', + uitype: 'code', + label: '', + placeholder: '选择模型', + cwidth: 12, + dataurl: opts.model_dataurl || '', + valueField: 'model_id', + textField: 'model_id_text', + params: { valueField: 'model_id', textField: 'model_id_text' } + }] + }); + + // add file button + var addfilew = new bricks.Svg({ + cwidth: 1.5, cheight: 1.5, + url: bricks_resource('imgs/add.svg') + }); + addfilew.bind('click', this.add_file.bind(this)); + + // submit button + var inputw = new bricks.Svg({ + cwidth: 1.5, cheight: 1.5, + url: opts.url || bricks_resource('imgs/submit.svg') + }); + inputw.bind('click', this.input_finished.bind(this)); + + // button row: [add_file] [model_selector] [filler] [submit] + var hbox = new bricks.HBox({cheight: 1.5, gap: '4px', alignItems: 'center'}); + hbox.add_widget(addfilew); + hbox.add_widget(this.model_selector); + hbox.add_widget(new bricks.VBox({css: 'filler'})); + hbox.add_widget(inputw); + + // assemble + this.add_widget(this.inputfilew); + this.add_widget(this.filesbar); + this.add_widget(this.textw); + this.add_widget(hbox); + + this.filesbar.hide(); + this.inputfilew.hide(); + } + + input_finished() { + var txt = this.textw.getValue(); + if (!txt.prompt || txt.prompt.length < 1) return; + var p = this.params || {}; + var mv = this.model_selector.getValue() || {}; + var d = Object.assign({}, p, { + add_files: this.add_files, + prompt: txt.prompt, + model_id: mv.model_id || '' + }); + this.dispatch('inputed', d); + this.textw.setValue(''); + this.add_files = []; + } + + file_added(e) { + this.inputfilew.hide(); + var file = this.inputfilew.getValue().add_file; + this.inputfilew.reset(); + this.add_files.push(file); + this.filesbar.clear_widgets(); + var w = new bricks.DeletableLabel({label: file.name}); + this.filesbar.add_widget(w); + this.filesbar.show(); + w.bind('deleted', this.deleted_file.bind(this, file)); + } + + deleted_file(file) { + this.add_files = this.add_files.filter(i => i !== file); + if (this.add_files.length === 0) this.filesbar.hide(); + } + + add_file() { + this.inputfilew.show(); + } + + getValue() { + var mv = this.model_selector.getValue() || {}; + return { + prompt: (this.textw.getValue() || {}).prompt || '', + model_id: mv.model_id || '' + }; + } +}; + +bricks.Factory.register('AgentInput', bricks.AgentInput); diff --git a/wwwroot/index.ui b/wwwroot/index.ui index 7bbb298..2c1de36 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -19,13 +19,13 @@ { "widgettype": "Title2", "options": { - "text": "\u5f00\u53d1\u4ea7\u7ebf\u9a7e\u9a76\u8231" + "text": "开发产线驾驶舱" } }, { "widgettype": "Text", "options": { - "text": "AI\u9a71\u52a8\u7684\u5bf9\u8bdd\u5f0f\u5f00\u53d1", + "text": "AI驱动的对话式开发", "cfontsize": 0.9, "color": "#94a3b8" } @@ -51,7 +51,7 @@ "widgettype": "Button", "id": "project_label", "options": { - "label": "\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a\u52a0\u8f7d\u4e2d...", + "label": "📁 当前项目:加载中...", "css": "link", "action": "click" }, @@ -61,7 +61,7 @@ "event": "click", "actiontype": "script", "target": "self", - "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var pid=d.project_id||'';if(!pid){bricks.showError('\u8bf7\u5148\u9009\u62e9\u9879\u76ee');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'\u9879\u76ee\u540d\u79f0\uff1a'+(d.project_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'\u9879\u76eeID\uff1a'+pid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'\u5de5\u4f5c\u76ee\u5f55\uff1a'+(d.workspace_dir||'/d/pipeline/workspaces/'+pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'\u9879\u76ee\u8be6\u60c5',cwidth:36,cheight:16,auto_open:true});pw.content_w.add_widget(box);" + "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var pid=d.project_id||'';if(!pid){bricks.showError('请先选择项目');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'项目名称:'+(d.project_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'项目ID:'+pid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'工作目录:'+(d.workspace_dir||'/d/pipeline/workspaces/'+pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'项目详情',cwidth:36,cheight:16,auto_open:true});pw.content_w.add_widget(box);" } ] }, @@ -69,7 +69,7 @@ "widgettype": "Button", "id": "iteration_label", "options": { - "label": "\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a\u52a0\u8f7d\u4e2d...", + "label": "🔄 当前迭代:加载中...", "css": "link", "action": "click" }, @@ -79,7 +79,7 @@ "event": "click", "actiontype": "script", "target": "self", - "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var iid=d.iteration_id||'';var pid=d.project_id||'';if(!iid){bricks.showError('\u8bf7\u5148\u9009\u62e9\u8fed\u4ee3');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'\u8fed\u4ee3\u540d\u79f0\uff1a'+(d.iteration_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'\u8fed\u4ee3ID\uff1a'+iid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'\u6240\u5c5e\u9879\u76ee\uff1a'+(d.project_name||pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'\u8fed\u4ee3\u8be6\u60c5',cwidth:36,cheight:14,auto_open:true});pw.content_w.add_widget(box);" + "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var iid=d.iteration_id||'';var pid=d.project_id||'';if(!iid){bricks.showError('请先选择迭代');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'迭代名称:'+(d.iteration_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'迭代ID:'+iid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'所属项目:'+(d.project_name||pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'迭代详情',cwidth:36,cheight:14,auto_open:true});pw.content_w.add_widget(box);" } ] }, @@ -129,7 +129,7 @@ { "widgettype": "Text", "options": { - "text": "\u9009\u62e9\u4e00\u4e2a\u8fed\u4ee3\u540e\uff0c\u5728\u4e0b\u65b9\u8f93\u5165\u4f60\u7684\u9700\u6c42\u3002", + "text": "选择一个迭代后,在下方输入你的需求。", "cfontsize": 1, "color": "#64748b" } @@ -137,7 +137,7 @@ { "widgettype": "Text", "options": { - "text": "Agent \u5c06\u81ea\u52a8\u5206\u6790\u9700\u6c42\u3001\u751f\u6210\u8bbe\u8ba1\u3001\u9a71\u52a8\u4ea7\u7ebf\u6267\u884c\u3002", + "text": "Agent 将自动分析需求、生成设计、驱动产线执行。", "cfontsize": 0.85, "color": "#94a3b8" } @@ -148,7 +148,6 @@ }, { "widgettype": "VBox", - "id": "agent_input", "options": { "bgcolor": "#fff", "border": "1px solid #e2e8f0", @@ -158,71 +157,12 @@ }, "subwidgets": [ { - "widgettype": "HBox", - "options": { - "padding": "6px 14px 2px 14px", - "gap": "6px", - "alignItems": "center" - }, - "subwidgets": [ - { - "widgettype": "Text", - "options": { - "text": "\ud83e\udd16", - "cfontsize": 0.8 - } - }, - { - "widgettype": "Form", - "id": "input_model_selector", - "options": { - "name": "input_model_selector", - "cols": 1, - "fields": [ - { - "name": "model_id", - "uitype": "code", - "label": "", - "placeholder": "\u9009\u62e9\u6a21\u578b", - "cwidth": 12, - "dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy", - "valueField": "model_id", - "textField": "model_id_text", - "params": { - "valueField": "model_id", - "textField": "model_id_text" - } - } - ] - } - }, - { - "widgettype": "Filler" - }, - { - "widgettype": "Button", - "options": { - "label": "\u6a21\u578b\u914d\u7f6e", - "css": "small" - }, - "binds": [ - { - "wid": "self", - "event": "click", - "actiontype": "script", - "target": "self", - "script": "var pw=new bricks.PopupWindow({title:\"\\u6a21\\u578b\\u914d\\u7f6e\",cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:\"urlwidget\",options:{url:\"/pipeline_core/llm/index.ui\",method:\"GET\"}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});" - } - ] - } - ] - }, - { - "widgettype": "TextFiles", + "widgettype": "AgentInput", "id": "chat_input", "options": { - "bgcolor": "transparent", - "padding": "6px 14px 10px 14px" + "placeholder": "输入你的需求...", + "model_dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy", + "model_cwidth": 14 }, "binds": [ { @@ -230,7 +170,7 @@ "event": "inputed", "actiontype": "script", "target": "self", - "script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var el=bricks.getWidgetById('input_model_selector',bricks.app).getValue();if(el)mid=el.value||'';}catch(e){}var chat=bricks.getWidgetById('chat_scroll',bricks.app);var at=null;if(chat){var ub=new bricks.HBox({width:'100%'});var um=new bricks.VBox({width:'85%',alignSelf:'flex-end',bgcolor:'#dbeafe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});um.add_widget(new bricks.Text({text:'\\u4f60',cfontsize:0.75,color:'#2563eb',fontWeight:'bold'}));um.add_widget(new bricks.Text({text:p,cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'}));ub.add_widget(new bricks.VBox({css:'filler'}));ub.add_widget(um);ub.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/chat-user.svg')}));chat.add_widget(ub);var ab=new bricks.HBox({width:'100%'});var am=new bricks.VBox({width:'85%',alignSelf:'flex-start',bgcolor:'#e8f0fe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});am.add_widget(new bricks.Text({text:'Agent',cfontsize:0.75,color:'#3b82f6',fontWeight:'bold'}));at=new bricks.Text({text:'\\u6b63\\u5728\\u5206\\u6790\\u9700\\u6c42...',cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'});am.add_widget(at);ab.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/llm.svg')}));ab.add_widget(am);ab.add_widget(new bricks.VBox({css:'filler'}));chat.add_widget(ab);}var body='message_text='+encodeURIComponent(p)+'&iteration_id='+encodeURIComponent(iid)+'&model_id='+encodeURIComponent(mid)+'&action=send_message&file_paths='+encodeURIComponent(JSON.stringify(files.map(function(f){return f.name||f})));fetch('/pipeline-sdlc/api/cockpit_chat.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(r){if(r.success){if(at)at.set_text(r.agent_reply||'\\u5df2\\u5904\\u7406');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('\\u9519\\u8bef: '+(r.error||'\\u672a\\u77e5\\u9519\\u8bef'));}});" + "script": "var p=params.prompt;var files=params.add_files||[];var mid=params.model_id||'';var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var chat=bricks.getWidgetById('chat_scroll',bricks.app);var at=null;if(chat){var ub=new bricks.HBox({width:'100%'});var um=new bricks.VBox({width:'85%',alignSelf:'flex-end',bgcolor:'#dbeafe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});um.add_widget(new bricks.Text({text:'你',cfontsize:0.75,color:'#2563eb',fontWeight:'bold'}));um.add_widget(new bricks.Text({text:p,cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'}));ub.add_widget(new bricks.VBox({css:'filler'}));ub.add_widget(um);ub.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/chat-user.svg')}));chat.add_widget(ub);var ab=new bricks.HBox({width:'100%'});var am=new bricks.VBox({width:'85%',alignSelf:'flex-start',bgcolor:'#e8f0fe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});am.add_widget(new bricks.Text({text:'Agent',cfontsize:0.75,color:'#3b82f6',fontWeight:'bold'}));at=new bricks.Text({text:'正在分析需求...',cfontsize:0.85,color:'#64748b'});am.add_widget(at);ab.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/llm.svg')}));ab.add_widget(am);ab.add_widget(new bricks.VBox({css:'filler'}));chat.add_widget(ab);}var body='message_text='+encodeURIComponent(p)+'&iteration_id='+encodeURIComponent(iid)+'&model_id='+encodeURIComponent(mid)+'&action=send_message&file_paths='+encodeURIComponent(JSON.stringify(files.map(function(f){return f.name||f})));fetch('/pipeline-sdlc/api/cockpit_chat.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(r){if(r.success){if(at)at.set_text(r.agent_reply||'已处理');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('错误: '+(r.error||'未知错误'));}});" } ] } diff --git a/wwwroot/index_cockpit.ui b/wwwroot/index_cockpit.ui index 2fa6ee5..1bbefcb 100644 --- a/wwwroot/index_cockpit.ui +++ b/wwwroot/index_cockpit.ui @@ -19,13 +19,13 @@ { "widgettype": "Title2", "options": { - "text": "\u5f00\u53d1\u4ea7\u7ebf\u9a7e\u9a76\u8231" + "text": "开发产线驾驶舱" } }, { "widgettype": "Text", "options": { - "text": "AI\u9a71\u52a8\u7684\u5bf9\u8bdd\u5f0f\u5f00\u53d1", + "text": "AI驱动的对话式开发", "cfontsize": 0.9, "color": "#94a3b8" } @@ -70,7 +70,7 @@ "widgettype": "Button", "id": "project_label", "options": { - "label": "\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a\u52a0\u8f7d\u4e2d...", + "label": "📁 当前项目:加载中...", "css": "link", "action": "click" }, @@ -80,7 +80,7 @@ "event": "click", "actiontype": "script", "target": "self", - "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var pid=d.project_id||'';if(!pid){bricks.showError('\u8bf7\u5148\u9009\u62e9\u9879\u76ee');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'\u9879\u76ee\u540d\u79f0\uff1a'+(d.project_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'\u9879\u76eeID\uff1a'+pid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'\u5de5\u4f5c\u76ee\u5f55\uff1a'+(d.workspace_dir||'/d/pipeline/workspaces/'+pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'\u9879\u76ee\u8be6\u60c5',cwidth:36,cheight:16,auto_open:true});pw.content_w.add_widget(box);" + "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var pid=d.project_id||'';if(!pid){bricks.showError('请先选择项目');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'项目名称:'+(d.project_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'项目ID:'+pid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'工作目录:'+(d.workspace_dir||'/d/pipeline/workspaces/'+pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'项目详情',cwidth:36,cheight:16,auto_open:true});pw.content_w.add_widget(box);" } ] }, @@ -88,7 +88,7 @@ "widgettype": "Button", "id": "iteration_label", "options": { - "label": "\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a\u52a0\u8f7d\u4e2d...", + "label": "🔄 当前迭代:加载中...", "css": "link", "action": "click" }, @@ -98,7 +98,7 @@ "event": "click", "actiontype": "script", "target": "self", - "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var iid=d.iteration_id||'';var pid=d.project_id||'';if(!iid){bricks.showError('\u8bf7\u5148\u9009\u62e9\u8fed\u4ee3');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'\u8fed\u4ee3\u540d\u79f0\uff1a'+(d.iteration_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'\u8fed\u4ee3ID\uff1a'+iid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'\u6240\u5c5e\u9879\u76ee\uff1a'+(d.project_name||pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'\u8fed\u4ee3\u8be6\u60c5',cwidth:36,cheight:14,auto_open:true});pw.content_w.add_widget(box);" + "script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var iid=d.iteration_id||'';var pid=d.project_id||'';if(!iid){bricks.showError('请先选择迭代');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'迭代名称:'+(d.iteration_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'迭代ID:'+iid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'所属项目:'+(d.project_name||pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'迭代详情',cwidth:36,cheight:14,auto_open:true});pw.content_w.add_widget(box);" } ] }, @@ -108,7 +108,7 @@ "options": { "dataurl": "/pipeline-sdlc/api/cockpit_context.dspy", "method": "GET", - "datascript": "(function(d){var d=d||{};var pl=bricks.getWidgetById('project_label',bricks.app);var il=bricks.getWidgetById('iteration_label',bricks.app);var pn=d.project_name||'';if(pl){pl.setText(pn?'\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a'+pn:'\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a--');}if(il){il.setText(d.iteration_name?(d.iteration_name.length>15?d.iteration_name.slice(0,15)+'...':d.iteration_name):'\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a--');il.setText('\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a'+(d.iteration_name||'--'));}return d;})" + "datascript": "(function(d){var d=d||{};var pl=bricks.getWidgetById('project_label',bricks.app);var il=bricks.getWidgetById('iteration_label',bricks.app);var pn=d.project_name||'';if(pl){pl.setText(pn?'📁 当前项目:'+pn:'📁 当前项目:--');}if(il){il.setText(d.iteration_name?(d.iteration_name.length>15?d.iteration_name.slice(0,15)+'...':d.iteration_name):'🔄 当前迭代:--');il.setText('🔄 当前迭代:'+(d.iteration_name||'--'));}return d;})" } } ] @@ -148,7 +148,7 @@ { "widgettype": "Text", "options": { - "text": "\u9009\u62e9\u4e00\u4e2a\u8fed\u4ee3\u540e\uff0c\u5728\u4e0b\u65b9\u8f93\u5165\u4f60\u7684\u9700\u6c42\u3002", + "text": "选择一个迭代后,在下方输入你的需求。", "cfontsize": 1, "color": "#64748b" } @@ -156,7 +156,7 @@ { "widgettype": "Text", "options": { - "text": "Agent \u5c06\u81ea\u52a8\u5206\u6790\u9700\u6c42\u3001\u751f\u6210\u8bbe\u8ba1\u3001\u9a71\u52a8\u4ea7\u7ebf\u6267\u884c\u3002", + "text": "Agent 将自动分析需求、生成设计、驱动产线执行。", "cfontsize": 0.85, "color": "#94a3b8" } @@ -167,7 +167,6 @@ }, { "widgettype": "VBox", - "id": "agent_input", "options": { "bgcolor": "#fff", "border": "1px solid #e2e8f0", @@ -177,71 +176,12 @@ }, "subwidgets": [ { - "widgettype": "HBox", - "options": { - "padding": "6px 14px 2px 14px", - "gap": "6px", - "alignItems": "center" - }, - "subwidgets": [ - { - "widgettype": "Text", - "options": { - "text": "\ud83e\udd16", - "cfontsize": 0.8 - } - }, - { - "widgettype": "Form", - "id": "input_model_selector", - "options": { - "name": "input_model_selector", - "cols": 1, - "fields": [ - { - "name": "model_id", - "uitype": "code", - "label": "", - "placeholder": "\u9009\u62e9\u6a21\u578b", - "cwidth": 12, - "dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy", - "valueField": "model_id", - "textField": "model_id_text", - "params": { - "valueField": "model_id", - "textField": "model_id_text" - } - } - ] - } - }, - { - "widgettype": "Filler" - }, - { - "widgettype": "Button", - "options": { - "label": "\u6a21\u578b\u914d\u7f6e", - "css": "small" - }, - "binds": [ - { - "wid": "self", - "event": "click", - "actiontype": "script", - "target": "self", - "script": "var pw=new bricks.PopupWindow({title:\"\\u6a21\\u578b\\u914d\\u7f6e\",cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:\"urlwidget\",options:{url:\"/pipeline_core/llm/index.ui\",method:\"GET\"}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});" - } - ] - } - ] - }, - { - "widgettype": "TextFiles", + "widgettype": "AgentInput", "id": "chat_input", "options": { - "bgcolor": "transparent", - "padding": "6px 14px 10px 14px" + "placeholder": "输入你的需求...", + "model_dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy", + "model_cwidth": 14 }, "binds": [ { @@ -249,7 +189,7 @@ "event": "inputed", "actiontype": "script", "target": "self", - "script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var ms=bricks.getWidgetById('input_model_selector',bricks.app);if(ms){var v=ms.getValue();mid=(v||{}).model_id||'';}}catch(e){}var chat=bricks.getWidgetById('chat_scroll',bricks.app);var at=null;if(chat){var ub=new bricks.HBox({width:'100%'});var um=new bricks.VBox({width:'85%',alignSelf:'flex-end',bgcolor:'#dbeafe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});um.add_widget(new bricks.Text({text:'\\\u4f60',cfontsize:0.75,color:'#2563eb',fontWeight:'bold'}));um.add_widget(new bricks.Text({text:p,cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'}));ub.add_widget(new bricks.VBox({css:'filler'}));ub.add_widget(um);ub.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/chat-user.svg')}));chat.add_widget(ub);var ab=new bricks.HBox({width:'100%'});var am=new bricks.VBox({width:'85%',alignSelf:'flex-start',bgcolor:'#e8f0fe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});am.add_widget(new bricks.Text({text:'Agent',cfontsize:0.75,color:'#3b82f6',fontWeight:'bold'}));at=new bricks.Text({text:'\\\u6b63\\\u5728\\\u5206\\\u6790\\\u9700\\\u6c42...',cfontsize:0.85,color:'#64748b'});am.add_widget(at);ab.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/llm.svg')}));ab.add_widget(am);ab.add_widget(new bricks.VBox({css:'filler'}));chat.add_widget(ab);}var body='message_text='+encodeURIComponent(p)+'&iteration_id='+encodeURIComponent(iid)+'&model_id='+encodeURIComponent(mid)+'&action=send_message&file_paths='+encodeURIComponent(JSON.stringify(files.map(function(f){return f.name||f})));fetch('/pipeline-sdlc/api/cockpit_chat.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(r){if(r.success){if(at)at.set_text..." + "script": "var p=params.prompt;var files=params.add_files||[];var mid=params.model_id||'';var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var chat=bricks.getWidgetById('chat_scroll',bricks.app);var at=null;if(chat){var ub=new bricks.HBox({width:'100%'});var um=new bricks.VBox({width:'85%',alignSelf:'flex-end',bgcolor:'#dbeafe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});um.add_widget(new bricks.Text({text:'你',cfontsize:0.75,color:'#2563eb',fontWeight:'bold'}));um.add_widget(new bricks.Text({text:p,cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'}));ub.add_widget(new bricks.VBox({css:'filler'}));ub.add_widget(um);ub.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/chat-user.svg')}));chat.add_widget(ub);var ab=new bricks.HBox({width:'100%'});var am=new bricks.VBox({width:'85%',alignSelf:'flex-start',bgcolor:'#e8f0fe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});am.add_widget(new bricks.Text({text:'Agent',cfontsize:0.75,color:'#3b82f6',fontWeight:'bold'}));at=new bricks.Text({text:'正在分析需求...',cfontsize:0.85,color:'#64748b'});am.add_widget(at);ab.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/llm.svg')}));ab.add_widget(am);ab.add_widget(new bricks.VBox({css:'filler'}));chat.add_widget(ab);}var body='message_text='+encodeURIComponent(p)+'&iteration_id='+encodeURIComponent(iid)+'&model_id='+encodeURIComponent(mid)+'&action=send_message&file_paths='+encodeURIComponent(JSON.stringify(files.map(function(f){return f.name||f})));fetch('/pipeline-sdlc/api/cockpit_chat.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(r){if(r.success){if(at)at.set_text(r.agent_reply||'已处理');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('错误: '+(r.error||'未知错误'));}});" } ] }