Files
AIDC-AI-ComfyUI-Copilot/dist/copilot_web/DebugGuide-DlOSuqF7.js
T
2025-06-27 11:52:22 +08:00

5 lines
2.2 KiB
JavaScript

function getImportPath(filename) {
return `./${filename}`;
}
import{j as r}from"./vendor-markdown-Mq66gLHN.js";import{r as f}from"./vendor-react-6F4zURhM.js";import{B as b,a as m,g as l,W as w}from"./message-components-CP6ZQyhw.js";import{q as h}from"./queuePrompt-Cm8deVJl.js";import"./workflowChat-CQWc5SUC.js";import"./input.js";/* empty css */function O({content:g,name:d="Assistant",avatar:y,onAddMessage:i}){const[a,c]=f.useState(!1);let u;try{u=JSON.parse(g)}catch(s){return console.error("Failed to parse message content:",s),null}const p=async()=>{if(!a){c(!0);try{const s=await m.graphToPrompt();console.log("Current workflow:",s);const e=await h([]);if(console.log("Queue response:",e),e.error||e.node_errors)await x(e);else{const t={id:l(),role:"ai",content:JSON.stringify({text:"Great! I tested your workflow and it appears to be working correctly. No errors were found during the validation process.",ext:[]}),format:"markdown",name:"Assistant"};i?.(t)}}finally{c(!1)}}},x=async s=>{try{const e=await m.graphToPrompt();let t="",n=null;for await(const o of w.streamDebugAgent(s,e))o.text&&(t=o.text,o.ext&&(n=o.ext));if(t){const o={id:l(),role:"ai",content:JSON.stringify({text:t,ext:n||[]}),format:"markdown",name:"Assistant"};i?.(o)}}catch(e){console.error("Error calling debug agent:",e);const t=e,n={id:l(),role:"ai",content:JSON.stringify({text:`I encountered an error while analyzing your workflow: ${t.message||"Unknown error"}`,ext:[]}),format:"markdown",name:"Assistant"};i?.(n)}};return r.jsx(b,{name:d,children:r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"text-sm text-gray-600 mb-3",children:u.text}),r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-blue-50 rounded-lg border border-blue-200",children:[r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-blue-800",children:"Would you like me to help debug this workflow?"})}),r.jsx("button",{onClick:p,disabled:a,className:`px-4 py-2 rounded-md transition-colors text-sm font-medium ${a?"bg-gray-400 text-gray-600 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600 text-white"}`,children:a?"Debugging...":"Debug"})]})]})})}export{O as DebugGuide};