fix: comfydeploy npm code display

This commit is contained in:
bennykok 2024-01-31 18:00:31 +08:00
parent 967a77d3a3
commit d4d7e98487

View File

@ -69,13 +69,16 @@ const client = new ComfyDeployClient({
`; `;
const jsClientCreateRunTemplate = ` const jsClientCreateRunTemplate = `
const { run_id } = await client.run("<ID>", { const { run_id } = await client.run({
deployment_id: "<ID>",
inputs: {} inputs: {}
}); });
`; `;
const jsClientCreateRunNoInputsTemplate = ` const jsClientCreateRunNoInputsTemplate = `
const { run_id } = await client.run("<ID>"); const { run_id } = await client.run({
deployment_id: "<ID>"
});
`; `;
const clientTemplate_checkStatus = ` const clientTemplate_checkStatus = `
@ -119,10 +122,7 @@ export function DeploymentDisplay({
<TabsContent className="flex flex-col gap-2 !mt-0" value="client"> <TabsContent className="flex flex-col gap-2 !mt-0" value="client">
<div> <div>
Install the node comfydeploy SDK Install the node comfydeploy SDK
<CodeBlock <CodeBlock lang="bash" code={`npm i comfydeploy`} />
lang="bash"
code={`npm i comfydeploy`}
/>
Initialize your client Initialize your client
</div> </div>
<CodeBlock <CodeBlock
@ -197,8 +197,7 @@ function formatCode(
if (inputs && inputs.length > 0) { if (inputs && inputs.length > 0) {
codeTemplate = codeTemplate.replace( codeTemplate = codeTemplate.replace(
"inputs: {}", "inputs: {}",
`inputs: ${ `inputs: ${JSON.stringify(
JSON.stringify(
Object.fromEntries( Object.fromEntries(
inputs.map((x) => { inputs.map((x) => {
return [x?.input_id, ""]; return [x?.input_id, ""];
@ -209,8 +208,7 @@ function formatCode(
) )
.split("\n") .split("\n")
.map((line, index) => (index === 0 ? line : ` ${line}`)) // Add two spaces indentation except for the first line .map((line, index) => (index === 0 ? line : ` ${line}`)) // Add two spaces indentation except for the first line
.join("\n") .join("\n")}`,
}`,
); );
} else { } else {
codeTemplate = codeTemplate.replace( codeTemplate = codeTemplate.replace(