Skip to content

Commit 9bf0cf3

Browse files
author
multimodalart
committed
escape quotes
1 parent 00f6607 commit 9bf0cf3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function nameWithoutNamespace(modelId: string): string {
99
return splitted.length === 1 ? splitted[0] : splitted[1];
1010
}
1111

12+
const escapeQuotes = (str: string | undefined): string | undefined => str?.replace(/"/g, '\\"');
13+
1214
//#region snippets
1315

1416
export const adapters = (model: ModelData): string[] => [
@@ -141,7 +143,7 @@ const diffusers_default = (model: ModelData) => [
141143
142144
pipe = DiffusionPipeline.from_pretrained("${model.id}")
143145
144-
prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersDefaultPrompt}"
146+
prompt = "${escapeQuotes(get_prompt_from_diffusers_model(model)) ?? diffusersDefaultPrompt}"
145147
image = pipe(prompt).images[0]`,
146148
];
147149

@@ -160,7 +162,7 @@ const diffusers_lora = (model: ModelData) => [
160162
pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
161163
pipe.load_lora_weights("${model.id}")
162164
163-
prompt = "${get_prompt_from_diffusers_model(model) ?? diffusersDefaultPrompt}"
165+
prompt = "${escapeQuotes(get_prompt_from_diffusers_model(model)) ?? diffusersDefaultPrompt}"
164166
image = pipe(prompt).images[0]`,
165167
];
166168

0 commit comments

Comments
 (0)