Skip to content

Commit 6c9b6bf

Browse files
[Snippets] Fix text-to-image fetch snippets (#1317)
with @Wauplin, we realized that some `text-to-image` js snippets were incorrect, the key use to pass the prompt is different from a provider to another, so it's better to get the inputs from the body instead. **EDIT**: this PR does not fix totally the issue, since the input keys are customized per provider in the `textToImage` function. This is fixed in #1315. **EDIT 2**: in a later PR we will apply a linter on the generated snippets which should make the snippets much nicer!
1 parent a74e4ee commit 6c9b6bf

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/inference/src/snippets/templates/js/fetch/textToImage.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function query(data) {
1414
return result;
1515
}
1616

17-
query({ inputs: {{ providerInputs.asObj.inputs }} }).then((response) => {
17+
18+
query({ {{ providerInputs.asTsString }} }).then((response) => {
1819
// Use image
1920
});

packages/tasks-gen/snippets-fixtures/text-to-image/js/fetch/0.fal-ai.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function query(data) {
1414
return result;
1515
}
1616

17-
query({ inputs: "Astronaut riding a horse" }).then((response) => {
17+
18+
query({ inputs: "\"Astronaut riding a horse\"", }).then((response) => {
1819
// Use image
1920
});

packages/tasks-gen/snippets-fixtures/text-to-image/js/fetch/0.hf-inference.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function query(data) {
1414
return result;
1515
}
1616

17-
query({ inputs: "Astronaut riding a horse" }).then((response) => {
17+
18+
query({ inputs: "\"Astronaut riding a horse\"", }).then((response) => {
1819
// Use image
1920
});

0 commit comments

Comments
 (0)