feat: temp

This commit is contained in:
ai-business-hql
2025-06-27 11:52:22 +08:00
parent 762d5c749f
commit 8d30fec938
18 changed files with 758 additions and 13 deletions
+5 -10
View File
@@ -8,21 +8,16 @@ import server
# LLM model configuration
llm_config: List[Dict[str, Any]] = [
{
"label": "gemini-2.5-flash",
"name": "gemini-2.5-flash-preview-04-17",
"image_enable": True
},
{
"label": "gpt-4.1",
"name": "gpt-4.1-2025-04-14-GlobalStandard",
"image_enable": True,
},
{
"label": "gpt-4o-mini",
"name": "gpt-4o-mini",
"image_enable": True,
},
{
"label": "gemini-2.5-flash",
"name": "gemini-2.5-flash-preview-04-17",
"image_enable": True
},
{
"label": "qwen-plus",
"name": "qwen-plus",
+2 -3
View File
@@ -85,8 +85,7 @@ async def comfyui_agent_invoke(messages: List[Dict[str, Any]], images: List[Imag
You must adhere to the following constraints to complete the task:
- [Important!] Respond must in the language used by the user in their question. Regardless of the language returned by the tools being called, please return the results based on the language used in the user's query. For example, if user ask by English, you must return in English.
- Use only one tool for each decision you make.
- [Important!] Respond must in the language used by the user in their question. Regardless of the language returned by the tools being called, please return the results based on the language used in the user's query. For example, if user ask by English, you must return
- Ensure that the commands or tools you invoke are within the provided tool list.
- If the execution of a command or tool fails, try changing the parameters or their format before attempting again.
- Your generated responses must follow the factual information given above. Do not make up information.
@@ -98,6 +97,7 @@ You must adhere to the following constraints to complete the task:
- Before performing any analysis or calculation, ensure that all sub-concepts involved have been defined.
- Printing the entire content of a file is strictly prohibited, as such actions have high costs and can lead to unforeseen consequences.
- Ensure that when you call a tool, you have obtained all the input variables for that tool, and do not fabricate any input values for it.
- When the user's intent is to get workflows or generate images with specific requirements, call both recall_workflow and gen_workflow tools simultaneously to provide comprehensive workflow options.
- When the user's intent is to query, return the query result directly without attempting to assist the user in performing operations.
- When the user's intent is to get prompts for image generation (like Stable Diffusion). Use specific descriptive language with proper weight modifiers (e.g., (word:1.2)), prefer English terms, and separate elements with commas. Include quality terms (high quality, detailed), style specifications (realistic, anime), lighting (cinematic, golden hour), and composition (wide shot, close up) as needed. When appropriate, include negative prompts to exclude unwanted elements. Return words divided by commas directly without any additional text.
- When a user pastes text that appears to be an error message (containing terms like "Failed", "Error", or stack traces), prioritize providing troubleshooting help rather than invoking search tools. Follow these steps:
@@ -113,7 +113,6 @@ You must adhere to the following constraints to complete the task:
- Alternative approaches if the extension is problematic
5. Suggest preventative measures to avoid similar errors
6. Do NOT automatically invoke search_node or other tools when processing error messages unless specifically requested
- When user provides images, analyze them carefully and incorporate the visual information into your responses and recommendations.
- Ensure your responses do not contain illegal or offensive information.
""",
mcp_servers=[server],
+14
View File
@@ -0,0 +1,14 @@
function getImportPath(filename) {
return `./${filename}`;
}
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-CQWc5SUC.js","copilot_web/input.js","copilot_web/vendor-markdown-Mq66gLHN.js","copilot_web/vendor-react-6F4zURhM.js","copilot_web/message-components-CP6ZQyhw.js","copilot_web/assets/input-CSq6s1bF.css","copilot_web/fonts.css"].map(path => {
const apiBase = window.comfyAPI?.api?.api?.api_base;
if (apiBase) {
// 有 API base 时,使用完整路径
return `${apiBase.substring(1)}/${path}`;
} else {
// 没有 API base 时,使用相对路径
return `./${path}`;
}
}))))=>i.map(i=>d[i]);
import{_ as a}from"./input.js";import{j as t}from"./vendor-markdown-Mq66gLHN.js";import{r,R as i}from"./vendor-react-6F4zURhM.js";import{C as n}from"./message-components-CP6ZQyhw.js";/* empty css */const o={EXPLAIN_NODE:"copilot:explain-node"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-CQWc5SUC.js")).then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function p(){const[e,s]=r.useState(!1);return r.useEffect(()=>{const l=()=>{s(!0)};return window.addEventListener(o.EXPLAIN_NODE,l),()=>window.removeEventListener(o.EXPLAIN_NODE,l)},[]),t.jsx(n,{children:t.jsx("div",{className:"h-full w-full flex flex-col",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:t.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>s(!1)})})})})}export{p as default};
+4
View File
@@ -0,0 +1,4 @@
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};
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as s}from"./vendor-markdown-Mq66gLHN.js";import{W as x,g as j,a as d}from"./message-components-CP6ZQyhw.js";import{r as P}from"./vendor-react-6F4zURhM.js";function G({content:C,name:D="Assistant",avatar:H,latestInput:N,installedNodes:z,onAddMessage:y}){const _=JSON.parse(C),v=_.ext?.find(e=>e.type==="workflow")?.data||[],[p,g]=P.useState({}),W=async e=>{if(!e.id){console.error("No workflow id provided");return}const i=String(e.id);if(!p[i]){g(t=>({...t,[i]:!0})),x.trackEvent({event_type:"workflow_accept",message_type:"workflow",message_id:_.message_id,data:{workflow_id:e.id,workflow_name:e.name}});try{const t=await x.getOptimizedWorkflow(e.id,N);if(t.workflow){const r=new Set;if(t.workflow.nodes)for(const o of t.workflow.nodes)r.add(o.type);else for(const o of Object.values(t.workflow))r.add(o.class_type);const a=Array.from(r).filter(o=>!z.includes(o));if(console.log("[WorkflowOption] Missing node types:",a),a.length>0){try{console.log("[WorkflowOption] Fetching info for missing nodes");const o=await x.batchGetNodeInfo(a);console.log("[WorkflowOption] Received node infos:",o);const m={text:"",ext:[{type:"node_install_guide",data:o.map(l=>({name:l.name,repository_url:l.github_url}))}]},c={id:j(),role:"ai",content:JSON.stringify(m),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:t.workflow,optimizedParams:t.optimized_params}};y?.(c)}catch(o){console.error("[WorkflowOption] Error fetching node info:",o),alert("Error checking required nodes. Please try again.")}finally{g(o=>({...o,[i]:!1}))}return}O(t.workflow,t.optimized_params)}}catch(t){console.error("Failed to optimize workflow:",t),alert("Failed to optimize workflow. Please try again.")}finally{g(t=>({...t,[i]:!1}))}}},O=(e,i)=>{if(e.nodes)d.loadGraphData(e);else{d.loadApiJson(e);const r=Object.keys(e),a=Object.keys(d.graph._nodes_by_id)[0],o=d.graph._nodes_by_id[a],m=o?o.pos[0]:0,c=o?o.pos[1]:0,l=250,f=60,A=20,E=60,b=50,I=1e3;let k=m,h=c,u=0;for(const F of r){const n=d.graph._nodes_by_id[F];if(n){u>I&&(k+=l+E,u=0,h=c);const M=n.inputs?n.inputs.length:0,S=n.outputs?n.outputs.length:0,J=n.widgets?n.widgets.length:0,L=Math.max(M,S)+J,w=A*L+f;n.size[0]=l,n.size[1]=w,n.pos[0]=k,n.pos[1]=h,u+=w+b,h+=w+b}}}for(const[r,a,o,m,c]of i){const l=d.graph._nodes_by_id[r].widgets;for(const f of l)f.name===m&&(f.value=c)}d.graph.setDirtyCanvas(!1,!0);const t={id:j(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};y?.(t)};return s.jsx("div",{className:"space-y-3",children:v.length>0&&s.jsx("div",{className:"flex flex-col space-y-4",children:v.map((e,i)=>{const t=e.id?String(e.id):"";return s.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&s.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:r=>{const a=r.target;a.onerror=null,a.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),s.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[s.jsx("div",{children:s.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),s.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&s.jsxs("div",{className:"relative group",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),s.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:s.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),s.jsx("button",{onClick:()=>W(e),disabled:p[t],className:`px-3 py-1.5 ${p[t]?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"} text-white rounded-md transition-colors text-xs`,children:p[t]?"Loading...":"Accept"})]})]})]},i)})})})}export{G as WorkflowOption};
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="cc-icon-logo" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xe900;" glyph-name="cc-icon-logo" horiz-adv-x="1673"
d="M953.240 271.522c7.894-6.874 12.965-16.634 19.585-24.709 11.100-13.542 23.393-25.939 36.892-37.094 56.683-46.839 134.714-63.303 205.904-46.280 36.563 8.744 71.347 27.153 98.834 52.889 6.503 6.089 26.996 19.767 21.187 30.485-9.427 17.396-31.912 31.962-45.898 45.893-4.414 4.397-10.841 13.638-17.632 14.025-8.042 0.458-18.046-13.623-23.549-18.443-14.098-12.353-30.474-20.840-48.239-26.551-86.646-27.857-171.451 32.122-189.787 118.031-19.441 91.078 54.091 198.993 153.313 189.040 24.603-2.468 46.791-9.195 68.243-21.640 8.668-5.028 22.977-21.652 32.930-21.475 6.976 0.124 13.251 9.647 17.670 14.093l36.477 36.459c6.590 6.636 14.250 12.156 6.741 21.193-15.330 18.450-37.542 32.228-58.519 43.305-118.109 62.355-262.374 13.472-323.782-103.311-35.469-67.452-25.685-150.041-68.487-214.140-30.167-45.177-80.951-74.275-136.022-70.413-19.842 1.391-39.756 6.076-57.653 14.847-104.915 51.407-113.944 202.931-23.532 272.699 38.111 29.409 90.649 36.425 135.309 18.880 11.810-4.640 22.625-10.821 32.945-18.183 4.417-3.151 10.625-9.812 16.473-9.484 6.426 0.363 12.309 8.692 16.473 12.855 11.977 11.973 23.349 24.496 35.298 36.475 4.345 4.355 14.559 11.600 12.080 18.825-3.723 10.854-20.787 20.481-29.729 26.835-33.085 23.507-73.643 37.831-114.130 40.263-129.389 7.774-246.857-87.826-260.937-218.877-11.557-107.563 36.224-215.138 135.041-266.113 84.024-43.342 187.873-30.941 261.204 27.158 19.671 15.585 46.151 38.408 55.300 62.466z" />
</font>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

+1
View File
File diff suppressed because one or more lines are too long
+38
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{r as g,g as f}from"./workflowChat-CQWc5SUC.js";import{a as c}from"./message-components-CP6ZQyhw.js";function p(o,t){try{if(!o)return console.error("Invalid prompt_output: ",o),o;for(const e of t){if(!o[e.nodeId]){console.error(`Node with ID ${e.nodeId} not found`);continue}if(!o[e.nodeId].inputs){console.error(`Inputs not found for node with ID ${e.nodeId}`);continue}o[e.nodeId].inputs[e.paramName]=e.paramValue}return o}catch(e){return console.error("Error updating prompt:",e),o}}async function x(o){const t=await c.graphToPrompt(),e=p(t.output,o);console.log("queuePrompt updated_prompt:",e);const s={prompt:e,client_id:c.api.clientId,extra_data:{extra_pageinfo:{workflow:t.workflow}}};console.debug("queuePrompt request_body.prompt:",e);const n=await g(s);return console.debug("queuePrompt response:",n),n}function u(o){const t=document.createElement("canvas"),e=t.getContext("2d");if(t.width=512,t.height=512,e){e.fillStyle="#f8d7da",e.fillRect(0,0,t.width,t.height),e.strokeStyle="#dc3545",e.lineWidth=4,e.strokeRect(10,10,t.width-20,t.height-20),e.fillStyle="#dc3545",e.beginPath(),e.arc(t.width/2,150,50,0,2*Math.PI),e.fill(),e.fillStyle="white",e.font="bold 80px Arial",e.textAlign="center",e.textBaseline="middle",e.fillText("!",t.width/2,150),e.fillStyle="#721c24",e.font="20px Arial",e.textAlign="center",e.textBaseline="middle";const s=t.width-60,n=30,i=o.split(" ");let r="",a=250;for(let l=0;l<i.length;l++){const d=r+i[l]+" ";e.measureText(d).width>s&&l>0?(e.fillText(r,t.width/2,a),r=i[l]+" ",a+=n):r=d}e.fillText(r,t.width/2,a)}return t.toDataURL("image/png")}async function m(o){try{if(!o||o==="")return console.log("No prompt ID provided"),{1:[u("Fail to generate prompt ID")]};const t=await f(o);if(!t||!t[o])return console.log("Not finished for prompt ID:",o),{};const e=t[o];if(e.status&&e.status.status_str==="error"){console.error("Error for prompt ID:",o);const n=e.status.messages;if(n&&n.length>0){const i=n[n.length-1];if(i&&i.length>0){const r=i[0];return{1:[u(r)]}}}}const s={};if(e.outputs)for(const n in e.outputs){const i=e.outputs[n];if(i&&i.images){s[n]=[];for(const r of i.images)if(r&&r.filename&&r.type){const a=c.graph._nodes_by_id[n].imgs[0].currentSrc.split("?")[0];s[n].push(a+"?filename="+encodeURIComponent(r.filename)+"&type="+encodeURIComponent(r.type)+(r.subfolder?"&subfolder="+encodeURIComponent(r.subfolder):""))}console.log("outputImages for nodeId:",n,s[n])}}return s}catch(t){throw console.error("Error getting output images from prompt:",t),t}}function b(){const o=Object.values(c.graph._nodes_by_id),t=[],e=[];for(const s of o)s.type==="SaveImage"?t.push(s.id):s.type==="PreviewImage"&&e.push(s.id);if(console.log("saveNodeIds:",t),console.log("previewNodeIds:",e),t.length===0&&e.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return t.length===1?t[0]:t.length==0&&e.length===1?e[0]:null}async function v(o,t){const e=await m(o);return Object.keys(e).length===0?null:e[t.toString()]&&e[t.toString()].length>0?e[t.toString()][0]:null}export{v as a,b as g,x as q};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
{
"name": "comfyui_copilot",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}