feat: checkpoint bug+改写经验优化

This commit is contained in:
ai-business-hql
2025-08-19 17:27:03 +08:00
parent b6587a6fc2
commit c1bdf24a08
12 changed files with 159 additions and 73 deletions
+12 -2
View File
@@ -20,10 +20,20 @@
"content": "添加图像反推节点(如CLIP Interrogator)\n{\n \"11\": {\n \"inputs\": {\n \"prompt_mode\": \"fast\",\n \"image_analysis\": \"off\"\n },\n \"class_type\": \"ClipInterrogator\",\n \"_meta\": {\n \"title\": \"Clip Interrogator ♾️Mixlab\"\n }\n }\n}\n - 添加更复杂或者更好用的图像反推节点(加载图片使用florence2进行反推)\n {\n \"6\": {\n \"inputs\": {\n \"image\": \"06.JPG\"\n },\n \"class_type\": \"LoadImage\",\n \"_meta\": {\n \"title\": \"$image.image!:The image to analyze, must be a url\"\n }\n },\n \"10\": {\n \"inputs\": {\n \"model\": \"microsoft/Florence-2-large\",\n \"precision\": \"fp16\",\n \"attention\": \"sdpa\"\n },\n \"class_type\": \"DownloadAndLoadFlorence2Model\",\n \"_meta\": {\n \"title\": \"DownloadAndLoadFlorence2Model\"\n }\n },\n \"11\": {\n \"inputs\": {\n \"text_input\": \"\",\n \"task\": \"more_detailed_caption\",\n \"fill_mask\": true,\n \"keep_model_loaded\": false,\n \"max_new_tokens\": 1024,\n \"num_beams\": 3,\n \"do_sample\": true,\n \"output_mask_select\": \"\",\n \"seed\": 1098631327477633,\n \"image\": [\n \"6\",\n 0\n ],\n \"florence2_model\": [\n \"10\",\n 0\n ]\n },\n \"class_type\": \"Florence2Run\",\n \"_meta\": {\n \"title\": \"Florence2Run\"\n }\n },\n \"18\": {\n \"inputs\": {\n \"anything\": [\n \"11\",\n 2\n ]\n },\n \"class_type\": \"easy showAnything\",\n \"_meta\": {\n \"title\": \"Show Any\"\n }\n },\n \"20\": {\n \"inputs\": {\n \"value\": \"Generate high-quality text descriptions from images using local Florence model.\\n \\n Main use cases:\\n 1. **Reverse image prompt generation**:\\n - When users upload an image and want to get prompts for AI art generation\\n - Analyzes visual elements, style, composition, etc. to generate prompts for Stable Diffusion, DALL-E, and other models\\n - In this case, return the tool's raw output directly to users without any modification or summary\\n - Users can directly use these prompts for image generation\\n 2. **Image content understanding**:\\n - When users ask about specific content, objects, scenes, people, etc. in the image\\n - Need to understand the semantic content of the image and answer users' specific questions\\n - In this case, combine tool output with conversation context to give users contextually appropriate natural responses\\n - Don't return raw output directly, but provide targeted replies based on understanding results\"\n },\n \"class_type\": \"PrimitiveStringMultiline\",\n \"_meta\": {\n \"title\": \"MCP\"\n }\n }\n}"
},
{
"name": "添加ControlNet",
"description": "在使用风格迁移保持主体结构不变、保持主体形状、重新绘制背景、控制人物角色姿态、保持场景的深度和空间结构、基于线稿或者草图生成图像等场景下,可以用添加ControlNet节点来实现",
"name": "sdxl特征保持",
"description": "当用户在使用sdxl工作流并需提及特征保持时优先推荐该类工作流,旨在保持图像的特征提取、保持主体结构不变、保持主体形状、控制人物角色姿态、保持场景的深度和空间结构、基于线稿或者草图生成图像等场景下,可以用添加ControlNet节点来实现",
"content": "**ControlNet集成**:(preprocessor可选canny、depth等参数,模型样式选择,Controlnet开始、结束权重)\n {\n \"22\": {\n \"inputs\": {\n \"strength\": 1,\n \"start_percent\": 0,\n \"end_percent\": 1,\n \"control_net\": [\n \"23\",\n 0\n ],\n \"image\": [\n \"24\",\n 0\n ]\n },\n \"class_type\": \"ControlNetApplyAdvanced\",\n \"_meta\": {\n \"title\": \"Apply ControlNet\"\n }\n },\n \"23\": {\n \"inputs\": {\n \"control_net_name\": \"ControlNet-Standard-Lineart-for-SDXL.safetensors\"\n },\n \"class_type\": \"ControlNetLoader\",\n \"_meta\": {\n \"title\": \"Load ControlNet Model\"\n }\n },\n \"24\": {\n \"inputs\": {\n \"preprocessor\": \"none\",\n \"resolution\": 512\n },\n \"class_type\": \"AIO_Preprocessor\",\n \"_meta\": {\n \"title\": \"AIO Aux Preprocessor\"\n }\n }\n}"
},
{
"name": "flux风格特征迁移",
"description": "当用户在使用flux的工作流并提及风格特征迁移时优先推荐该节点,该类节用途主要应用于flux工作流的图片风格特征迁移和提取,风格转换,两张图片参考迁移,重绘遮罩区域或重绘背景,使用时请先分析是否为flux工作流",
"content": "{\n \"1\": {\n \"inputs\": {\n \"downsampling_factor\": 3,\n \"downsampling_function\": \"area\",\n \"mode\": \"center crop (square)\",\n \"weight\": 1,\n \"autocrop_margin\": 0.1,\n \"style_model\": [\n \"2\",\n 0\n ],\n \"clip_vision\": [\n \"3\",\n 0\n ]\n },\n \"class_type\": \"ReduxAdvanced\",\n \"_meta\": {\n \"title\": \"ReduxAdvanced\"\n }\n },\n \"2\": {\n \"inputs\": {\n \"style_model_name\": \"flux1-redux-dev.safetensors\"\n },\n \"class_type\": \"StyleModelLoader\",\n \"_meta\": {\n \"title\": \"Load Style Model\"\n }\n },\n \"3\": {\n \"inputs\": {\n \"clip_name\": \"sigclip_vision_patch14_384.safetensors\"\n },\n \"class_type\": \"CLIPVisionLoader\",\n \"_meta\": {\n \"title\": \"Load CLIP Vision\"\n }\n }\n}"
},
{
"name": "sdxl特征迁移",
"description": "当用户在使用sdxl工作流并提及特征迁移时优先推荐该类工作流,旨在保持图像的特征提取、颜色提取,保持主体不变重绘背景或改变遮罩区域内容,可以用添加IPAdapter Advanced节点来实现",
"content": "**IPAdapter集成**:(weight type可选linear、ease in-out等参数,weight可选0.1-1开始、结束权重可选0.1-1) {\n \"1\": {\n \"inputs\": {\n \"weight\": 1,\n \"weight_type\": \"linear\",\n \"combine_embeds\": \"concat\",\n \"start_at\": 0,\n \"end_at\": 1,\n \"embeds_scaling\": \"V only\",\n \"ipadapter\": [\n \"2\",\n 0\n ],\n \"clip_vision\": [\n \"3\",\n 0\n ]\n },\n \"class_type\": \"IPAdapterAdvanced\",\n \"_meta\": {\n \"title\": \"IPAdapter Advanced\"\n }\n },\n \"2\": {\n \"inputs\": {\n \"ipadapter_file\": \"ip-adapter_sdxl_vit-h.safetensors\"\n },\n \"class_type\": \"IPAdapterModelLoader\",\n \"_meta\": {\n \"title\": \"IPAdapter Model Loader\"\n }\n },\n \"3\": {\n \"inputs\": {\n \"clip_name\": \"CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors\"\n },\n \"class_type\": \"CLIPVisionLoader\",\n \"_meta\": {\n \"title\": \"Load CLIP Vision\"\n }\n }\n}"
},
{
"name": "扩图",
"description": "给我一个扩图链路(包括图像加载和图像输出)",
@@ -176,6 +176,15 @@ def update_workflow(workflow_data: str = "") -> str:
}
})
if version_id:
ext_data.append({
"type": "workflow_rewrite_complete",
"data": {
"version_id": version_id,
"checkpoint_type": "workflow_rewrite_complete"
}
})
return json.dumps({
"success": True,
"version_id": version_id,
@@ -1,7 +1,7 @@
function getImportPath(filename) {
return `./${filename}`;
}
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-ACJkE2Mt.js","copilot_web/vendor-markdown-BAJQc3l1.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-DQGEQEMG.js","copilot_web/input.js","copilot_web/assets/input-Dx1yyZQD.css","copilot_web/fonts.css"].map(path => {
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-CWon1jsL.js","copilot_web/vendor-markdown-BAJQc3l1.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-bIY7IXFP.js","copilot_web/input.js","copilot_web/assets/input-Dx1yyZQD.css","copilot_web/fonts.css"].map(path => {
const apiBase = window.comfyAPI?.api?.api?.api_base;
if (apiBase) {
// 有 API base 时,使用完整路径
@@ -11,4 +11,4 @@ function getImportPath(filename) {
return `./${path}`;
}
}))))=>i.map(i=>d[i]);
import{_ as a}from"./input.js";import{j as o}from"./vendor-markdown-BAJQc3l1.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-DQGEQEMG.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-ACJkE2Mt.js")).then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function c(){const[e,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),o.jsx(n,{children:o.jsx("div",{className:"h-full w-full flex flex-col",children:o.jsx(t.Suspense,{fallback:o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:o.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
import{_ as a}from"./input.js";import{j as o}from"./vendor-markdown-BAJQc3l1.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-bIY7IXFP.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-CWon1jsL.js")).then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function c(){const[e,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),o.jsx(n,{children:o.jsx("div",{className:"h-full w-full flex flex-col",children:o.jsx(t.Suspense,{fallback:o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:o.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
@@ -1,5 +1,5 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as s}from"./vendor-markdown-BAJQc3l1.js";import{r as i}from"./vendor-react-Dixhfmvb.js";import{u as A,B as D,R as E,h as x,a as m,W as b}from"./message-components-DQGEQEMG.js";function M({content:f,name:k="Assistant",avatar:O,onAddMessage:y,onUpdateMessage:c,messageId:w}){const{dispatch:u,abortControllerRef:l}=A(),[d,_]=i.useState(!1),[T,G]=i.useState(""),[J,S]=i.useState(!1),[j,N]=i.useState(null),r=i.useMemo(()=>{try{return JSON.parse(f)}catch(e){return console.error("Failed to parse message content:",e),null}},[f]),h=i.useMemo(()=>{if(!r||!r.ext)return null;const e=r.ext.find(t=>t.type==="debug_start_checkpoint"||t.type==="debug_checkpoint"&&t.data?.checkpoint_type==="debug_start");return e&&e.data&&e.data.checkpoint_id?e.data.checkpoint_id:null},[r])||j,C=async()=>{if(d)return;const e=x(),t={id:e,role:"ai",content:JSON.stringify({text:`🔍 Starting workflow analysis...
import{j as s}from"./vendor-markdown-BAJQc3l1.js";import{r as i}from"./vendor-react-Dixhfmvb.js";import{u as A,B as D,R as E,h as x,a as m,W as b}from"./message-components-bIY7IXFP.js";function M({content:f,name:k="Assistant",avatar:O,onAddMessage:y,onUpdateMessage:c,messageId:w}){const{dispatch:u,abortControllerRef:l}=A(),[d,_]=i.useState(!1),[T,G]=i.useState(""),[J,S]=i.useState(!1),[j,N]=i.useState(null),r=i.useMemo(()=>{try{return JSON.parse(f)}catch(e){return console.error("Failed to parse message content:",e),null}},[f]),h=i.useMemo(()=>{if(!r||!r.ext)return null;const e=r.ext.find(t=>t.type==="debug_start_checkpoint"||t.type==="debug_checkpoint"&&t.data?.checkpoint_type==="debug_start");return e&&e.data&&e.data.checkpoint_id?e.data.checkpoint_id:null},[r])||j,C=async()=>{if(d)return;const e=x(),t={id:e,role:"ai",content:JSON.stringify({text:`🔍 Starting workflow analysis...
`,ext:[]}),format:"markdown",name:"Assistant",finished:!1,debugGuide:!0};y?.(t);try{await v(),u({type:"SET_LOADING",payload:!0}),await I(e)}finally{_(!1)}},v=async()=>{try{const e=await m.graphToPrompt(),t=localStorage.getItem("sessionId")||"";if(t&&e){const n=await b.saveWorkflowCheckpoint(t,e.output,e.workflow,"debug_start");if(N(n.version_id),console.log(`Saved debug start checkpoint: ${n.version_id}`),c&&r){const o=[...r.ext||[]].filter(g=>g.type!=="debug_start_checkpoint"&&!(g.type==="debug_checkpoint"&&g.data?.checkpoint_type==="debug_start"));o.push({type:"debug_start_checkpoint",data:{checkpoint_id:n.version_id,checkpoint_type:"debug_start"}});const p={id:w||x(),role:"ai",content:JSON.stringify({text:r.text,ext:o}),format:"debug_guide",name:"Assistant"};c(p)}}}catch(e){console.error("Failed to save checkpoint before debug:",e)}},I=async e=>{try{const t=await m.graphToPrompt();let n="",a=null;l&&(l.current=new AbortController);for await(const o of b.streamDebugAgent(t,l?.current?.signal||void 0))if(o.text){n=o.text,o.ext&&(a=o.ext);const p={id:e,role:"ai",content:JSON.stringify({text:n,ext:a||[]}),format:"markdown",name:"Assistant",finished:!1,debugGuide:!0};c?.(p)}c?.({id:e,role:"ai",content:JSON.stringify({text:n,ext:a||[]}),format:"markdown",name:"Assistant",finished:!0,debugGuide:!0}),u({type:"SET_LOADING",payload:!1}),l.current=null}catch(t){console.error("Error calling debug agent:",t),S(!1);const a={id:e,role:"ai",content:JSON.stringify({text:`I encountered an error while analyzing your workflow: ${t.message||"Unknown error"}`,ext:[]}),format:"markdown",name:"Assistant",finished:!0};c?.(a),u({type:"SET_LOADING",payload:!1}),l.current=null}};return r?s.jsx(D,{name:k,children:s.jsxs("div",{className:"bg-gray-100 pt-4 px-4 pb-3 rounded-lg",children:[s.jsx("div",{className:"flex justify-between items-start",children:s.jsx("p",{className:"text-gray-700 text-sm flex-1",children:r.text})}),s.jsx("div",{className:"flex justify-end mt-4",children:s.jsx("button",{onClick:C,disabled:d,className:`debug-btn bg-debug-btn text-sm text-[#fff] rounded-lg px-4 py-2 ${d?"cursor-not-allowed":"cursor-pointer"}`,children:d?"Analyzing...":"Debug Errors"})}),s.jsx("div",{className:"flex justify-end mt-2",children:!!h&&s.jsx("div",{className:"ml-2 flex-shrink-0",children:s.jsx(E,{checkpointId:h,onRestore:()=>{console.log("Workflow restored from checkpoint")}})})})]})}):null}export{M as DebugGuide};
@@ -1,4 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as e}from"./vendor-markdown-BAJQc3l1.js";import{b as f,c as h,B as m,p as u,R as w}from"./message-components-DQGEQEMG.js";import{r as k}from"./vendor-react-Dixhfmvb.js";import{B as j}from"./workflowChat-ACJkE2Mt.js";import"./input.js";/* empty css */import"./App-DBKTxFrw.js";const v=i=>{const{title:a="",isWorkflowUpdate:d=!1,className:n="",children:c}=i,[s,r]=k.useState(!1);return e.jsx(j,{className:"rounded-lg ",borderClassName:"rounded-lg",children:e.jsxs("div",{className:`flex flex-col ${n} ${s?"":"max-h-[200px]"}`,children:[e.jsxs("div",{className:"flex justify-between items-center pb-2 border-b border-gray-100",children:[e.jsx("div",{children:typeof a=="string"?e.jsx("h3",{className:"text-sm text-[#fff] font-medium",children:a}):a}),e.jsx("button",{onClick:()=>{r(!s)},children:s?e.jsx(f,{className:"text-gray-700"}):e.jsx(h,{className:"text-gray-700"})})]}),e.jsx("div",{className:"overflow-hidden flex-1",children:c})]})})};function B({content:i,name:a="Assistant",avatar:d,format:n="markdown"}){const c=()=>{let s=null,r=!1,o;try{if(o=JSON.parse(i),o.ext){let t=o.ext.find(l=>l.type==="workflow_rewrite_checkpoint"||l.type==="debug_checkpoint"&&l.data?.checkpoint_type==="workflow_rewrite_start");t&&t.data&&t.data.checkpoint_id?(s=t.data.checkpoint_id,r=!0):(t=o.ext.find(l=>l.type==="workflow_rewrite_complete"),t&&t.data&&t.data.version_id?(s=t.data.version_id,r=!0):(t=o.ext.find(l=>l.type==="debug_checkpoint"),t&&t.data&&t.data.checkpoint_id&&(s=t.data.checkpoint_id,r=!1))),o.ext.find(l=>l.type==="workflow_update")&&(r=!0)}}catch(t){return console.error("Failed to parse DebugResult content:",t),null}const x=r?e.jsxs("div",{className:"flex items-center text-green-500",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),e.jsx("h4",{className:"font-bold text-xl",children:"Workflow Updated Successfully"})]}):e.jsxs("div",{className:"flex items-center text-gray-900",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"28108",fill:"currentColor",children:e.jsx("path",{d:"M401.048025 844.855924c0 20.341281 16.643052 36.984333 36.984333 36.984333l147.936307 0c20.341281 0 36.984333-16.643052 36.984333-36.984333L622.952998 807.872614 401.048025 807.872614 401.048025 844.855924zM512 142.159744c-142.943596 0-258.888282 115.944686-258.888282 258.888282 0 88.021729 44.011376 165.503405 110.951975 212.288964l0 83.58365c0 20.341281 16.643052 36.984333 36.984333 36.984333l221.903949 0c20.341281 0 36.984333-16.643052 36.984333-36.984333l0-83.58365c66.941622-46.784536 110.951975-124.266212 110.951975-212.288964C770.888282 258.104429 654.943596 142.159744 512 142.159744zM617.588827 552.682561l-31.621185 22.005176 0 85.248569L438.031335 659.936307l0-85.063351L406.41015 552.866756c-49.743938-34.764781-79.33079-91.350544-79.33079-151.634536 0-101.890598 83.029018-184.92064 184.92064-184.92064s184.92064 83.029018 184.92064 184.92064C696.919617 461.332017 667.332764 517.91778 617.588827 552.682561z","p-id":"28277"})}),e.jsx("h4",{className:"font-bold text-xl",children:"Workflow Updated Finished"})]}),p=r?e.jsx("div",{className:"mt-3 text-xs text-gray-700",children:"💡 If you're not satisfied with the changes, click the restore button to revert to the previous version."}):null;return e.jsxs("div",{className:"sticky top-0 left-0 w-full bg-gray-100 p-4 rounded-lg overflow-hidden",children:[e.jsx(v,{title:x,isWorkflowUpdate:r,className:"p-4",children:e.jsxs("div",{className:"prose prose-sm max-w-none",children:[n==="markdown"?e.jsx(u,{response:o||{}}):e.jsx("pre",{className:"whitespace-pre-wrap text-gray-700 text-sm leading-relaxed h-full",children:o?.text||""}),p]})}),e.jsx("div",{className:"flex justify-end mt-2",children:!!s&&e.jsx("div",{className:"ml-2 flex-shrink-0",children:e.jsx(w,{checkpointId:s,onRestore:()=>{console.log(`Workflow restored from ${r?"workflow update":"debug"} checkpoint`)},title:r?`Restore to this version (Version ${s})`:`Restore checkpoint ${s}`})})})]})};return e.jsx(m,{name:a,children:c()})}export{B as DebugResult};
import{j as e}from"./vendor-markdown-BAJQc3l1.js";import{b as f,c as h,B as m,p as u,R as w}from"./message-components-bIY7IXFP.js";import{r as k}from"./vendor-react-Dixhfmvb.js";import{B as j}from"./workflowChat-CWon1jsL.js";import"./input.js";/* empty css */import"./App-COQCWIye.js";const v=i=>{const{title:a="",isWorkflowUpdate:d=!1,className:n="",children:c}=i,[s,r]=k.useState(!1);return e.jsx(j,{className:"rounded-lg ",borderClassName:"rounded-lg",children:e.jsxs("div",{className:`flex flex-col ${n} ${s?"":"max-h-[200px]"}`,children:[e.jsxs("div",{className:"flex justify-between items-center pb-2 border-b border-gray-100",children:[e.jsx("div",{children:typeof a=="string"?e.jsx("h3",{className:"text-sm text-[#fff] font-medium",children:a}):a}),e.jsx("button",{onClick:()=>{r(!s)},children:s?e.jsx(f,{className:"text-gray-700"}):e.jsx(h,{className:"text-gray-700"})})]}),e.jsx("div",{className:"overflow-hidden flex-1",children:c})]})})};function B({content:i,name:a="Assistant",avatar:d,format:n="markdown"}){const c=()=>{let s=null,r=!1,o;try{if(o=JSON.parse(i),o.ext){let t=o.ext.find(l=>l.type==="workflow_rewrite_checkpoint"||l.type==="debug_checkpoint"&&l.data?.checkpoint_type==="workflow_rewrite_start");t&&t.data&&t.data.checkpoint_id?(s=t.data.checkpoint_id,r=!0):(t=o.ext.find(l=>l.type==="workflow_rewrite_complete"),t&&t.data&&t.data.version_id?(s=t.data.version_id,r=!0):(t=o.ext.find(l=>l.type==="debug_checkpoint"),t&&t.data&&t.data.checkpoint_id&&(s=t.data.checkpoint_id,r=!1))),o.ext.find(l=>l.type==="workflow_update")&&(r=!0)}}catch(t){return console.error("Failed to parse DebugResult content:",t),null}const x=r?e.jsxs("div",{className:"flex items-center text-green-500",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),e.jsx("h4",{className:"font-bold text-xl",children:"Workflow Updated Successfully"})]}):e.jsxs("div",{className:"flex items-center text-gray-900",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"28108",fill:"currentColor",children:e.jsx("path",{d:"M401.048025 844.855924c0 20.341281 16.643052 36.984333 36.984333 36.984333l147.936307 0c20.341281 0 36.984333-16.643052 36.984333-36.984333L622.952998 807.872614 401.048025 807.872614 401.048025 844.855924zM512 142.159744c-142.943596 0-258.888282 115.944686-258.888282 258.888282 0 88.021729 44.011376 165.503405 110.951975 212.288964l0 83.58365c0 20.341281 16.643052 36.984333 36.984333 36.984333l221.903949 0c20.341281 0 36.984333-16.643052 36.984333-36.984333l0-83.58365c66.941622-46.784536 110.951975-124.266212 110.951975-212.288964C770.888282 258.104429 654.943596 142.159744 512 142.159744zM617.588827 552.682561l-31.621185 22.005176 0 85.248569L438.031335 659.936307l0-85.063351L406.41015 552.866756c-49.743938-34.764781-79.33079-91.350544-79.33079-151.634536 0-101.890598 83.029018-184.92064 184.92064-184.92064s184.92064 83.029018 184.92064 184.92064C696.919617 461.332017 667.332764 517.91778 617.588827 552.682561z","p-id":"28277"})}),e.jsx("h4",{className:"font-bold text-xl",children:"Workflow Updated Finished"})]}),p=r?e.jsx("div",{className:"mt-3 text-xs text-gray-700",children:"💡 If you're not satisfied with the changes, click the restore button to revert to the previous version."}):null;return e.jsxs("div",{className:"sticky top-0 left-0 w-full bg-gray-100 p-4 rounded-lg overflow-hidden",children:[e.jsx(v,{title:x,isWorkflowUpdate:r,className:"p-4",children:e.jsxs("div",{className:"prose prose-sm max-w-none",children:[n==="markdown"?e.jsx(u,{response:o||{}}):e.jsx("pre",{className:"whitespace-pre-wrap text-gray-700 text-sm leading-relaxed h-full",children:o?.text||""}),p]})}),e.jsx("div",{className:"flex justify-end mt-2",children:!!s&&e.jsx("div",{className:"ml-2 flex-shrink-0",children:e.jsx(w,{checkpointId:s,onRestore:()=>{console.log(`Workflow restored from ${r?"workflow update":"debug"} checkpoint`)},title:r?`Restore to this version (Version ${s})`:`Restore checkpoint ${s}`})})})]})};return e.jsx(m,{name:a,children:c()})}export{B as DebugResult};
@@ -1,7 +1,7 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as ue}from"./vendor-markdown-BAJQc3l1.js";import{W as Si,h as Wa,a as Wt}from"./message-components-DQGEQEMG.js";import{g as _u,R as Oe,b as Ba,r as h,d as Ca,a as Ou}from"./vendor-react-Dixhfmvb.js";var ns={exports:{}};/*!
import{j as ue}from"./vendor-markdown-BAJQc3l1.js";import{W as Si,h as Wa,a as Wt}from"./message-components-bIY7IXFP.js";import{g as _u,R as Oe,b as Ba,r as h,d as Ca,a as Ou}from"./vendor-react-Dixhfmvb.js";var ns={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
+3 -3
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+43 -2
View File
@@ -300,8 +300,29 @@ export namespace WorkflowChatAPI {
for (const line of lines) {
if (line.trim()) {
const response = JSON.parse(line) as ChatResponse;
// Add checkpoint info to first response if available
if (workflowCheckpointId && response.session_id === sessionId) {
const extWithCheckpoint = [
...(response.ext || []),
{
type: "user_message_checkpoint",
data: {
checkpoint_id: workflowCheckpointId,
message_id: userMessageId,
checkpoint_type: "user_message_checkpoint"
}
}
];
response.ext = extWithCheckpoint;
// Clear the checkpoint ID after adding it to prevent duplication
workflowCheckpointId = null;
}
yield {
...JSON.parse(line) as ChatResponse,
...response,
message_id: messageId
};
}
@@ -309,8 +330,28 @@ export namespace WorkflowChatAPI {
}
if (buffer.trim()) {
const response = JSON.parse(buffer) as ChatResponse;
// Add checkpoint info to final response if available (fallback)
if (workflowCheckpointId && response.session_id === sessionId) {
const extWithCheckpoint = [
...(response.ext || []),
{
type: "user_message_checkpoint",
data: {
checkpoint_id: workflowCheckpointId,
message_id: userMessageId,
checkpoint_type: "user_message_checkpoint"
}
}
];
response.ext = extWithCheckpoint;
workflowCheckpointId = null;
}
yield {
...JSON.parse(buffer) as ChatResponse,
...response,
message_id: messageId
};
}
@@ -51,11 +51,6 @@ export function UserMessage({ content, trace_id, ext }: UserMessageProps) {
console.log(`[UserMessage] Extracted checkpoint ID:`, checkpointId);
}
// Also check if there's workflow_update or param_update ext (user might want checkpoint for these)
const hasWorkflowUpdate = ext.some((item) =>
item.type === 'workflow_update' || item.type === 'param_update'
);
const hasImages = ext.some((item) => item.type === 'img');
if (hasImages) {
ext.filter((item) => item.type === 'img').forEach((item) => images = images.concat(item.data));
+31
View File
@@ -520,6 +520,37 @@ export default function WorkflowChat({ onClose, visible = true, triggerUsage = f
if (isFirstResponse) {
dispatch({ type: 'ADD_MESSAGE', payload: aiMessage });
// Check if response contains checkpoint info and update user message
const parsedResponse = JSON.parse(aiMessage.content);
if (parsedResponse.ext) {
const checkpointExt = parsedResponse.ext.find((item: any) =>
item.type === 'user_message_checkpoint' &&
item.data?.message_id === userMessageId
);
if (checkpointExt && checkpointExt.data?.checkpoint_id) {
console.log(`[WorkflowChat] Found checkpoint ID ${checkpointExt.data.checkpoint_id} for user message ${userMessageId}`);
// Update user message with checkpoint info
const updatedUserMessage: Message = {
...userMessage,
ext: [
...(userMessage.ext || []),
{
type: 'workflow_rewrite_checkpoint',
data: {
checkpoint_id: checkpointExt.data.checkpoint_id,
checkpoint_type: 'workflow_rewrite_start'
}
}
]
};
dispatch({ type: 'UPDATE_MESSAGE', payload: updatedUserMessage });
}
}
isFirstResponse = false;
} else {
dispatch({ type: 'UPDATE_MESSAGE', payload: aiMessage });