diff --git a/web/src/components/DeploymentDisplay.tsx b/web/src/components/DeploymentDisplay.tsx index 1ac54da..569cf28 100644 --- a/web/src/components/DeploymentDisplay.tsx +++ b/web/src/components/DeploymentDisplay.tsx @@ -23,44 +23,74 @@ import Link from "next/link"; const curlTemplate = ` curl --request POST \ --url \ - --header 'Content-Type: application/json' \ - --data '{ + --header "Content-Type: application/json" \ + --data "{ "deployment_id": "" -}' +}" `; const curlTemplate_checkStatus = ` curl --request GET \ - --url 'http://localhost:3000/api/run?run_id=xxx' \ - --header 'Content-Type: application/json' + --url "/api/run?run_id=xxx" \ + --header "Content-Type: application/json" `; const jsTemplate = ` -const { run_id } = await fetch('', { - method: 'POST', +const { run_id } = await fetch("", { + method: "POST", headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + process.env.COMFY_DEPLOY_API_KEY, + "Content-Type": "application/json", + "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, body: JSON.stringify({ - deployment_id: '', + deployment_id: "", inputs: {} }), }).then(response => response.json()) `; const jsTemplate_checkStatus = ` -const run_id = ''; +const run_id = ""; -const output = fetch('?run_id=' + run_id, { - method: 'GET', +const output = fetch("?run_id=" + run_id, { + method: "GET", headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + process.env.COMFY_DEPLOY_API_KEY, + "Content-Type": "application/json", + "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, }).then(response => response.json()) `; +const clientTemplate = ` +const client = new ComfyDeployClient({ + apiBase: "", + apiToken: process.env.COMFY_DEPLOY_API_KEY!, +}); + +export async function generateTextures(scrImageId: string) { + const result = await client.run("", { + input_image: "", + }); + if (!result || !result.run_id) return { error: "run id not found" }; + return { id: result.run_id }; +} +`; + +const clientTemplate_checkStatus = ` +const run_id = ""; + +while (true) { + const run = await client.getRun(run_id); + await new Promise((resolve) => setTimeout(resolve, 3000)); + + if (!run) continue; + run.outputs.map((val) => { + if (!val.data.image) return; + }); +} + +`; + export function DeploymentDisplay({ deployment, }: { @@ -91,21 +121,55 @@ export function DeploymentDisplay({ - + {deployment.environment} Deployment Code for your deployment client - + {deployment.environment !== "public-share" ? ( - - + + + client js curl - + +
+ Trigger the workflow with + +  comfy deploy wrapper + +
+
+ Copy the wrapper to your project, and import the function +
+ + Check the status of the run, and retrieve the outputs + +
+ Trigger the workflow - + ", `${domain ?? "http://localhost:3000"}/api/run`) - .replace("", deployment.id); + .replace("", deployment.id) + .replace("", domain ?? "http://localhost:3000"); }