Skip to content

[Inference] Overrides snippets inputs #1613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

krampstudio
Copy link
Collaborator

@krampstudio krampstudio commented Jul 11, 2025

So we can call

snippets.getInferenceSnippets(model, "auto", undefined, {
   inputs: `"A dog with a baseball cap"`
});

to get the following sample

# output is a PIL.Image object
image = client.text_to_image(
    "A dog with a baseball cap",
    model="black-forest-labs/FLUX.1-dev",
)

instead of the default input in the snippet:

image = client.text_to_image(
    "Astronaut riding a horse",
    model="black-forest-labs/FLUX.1-dev",
)

it's already possible to do it for text-generation with opts.mesages

needed for (internal https://github.com/huggingface-internal/moon-landing/pull/14421)

@@ -167,7 +167,9 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
const accessTokenOrPlaceholder = opts?.accessToken ?? placeholder;

/// Prepare inputs + make request
const inputs = inputPreparationFn ? inputPreparationFn(model, opts) : { inputs: getModelInputSnippet(model) };
const inputs = inputPreparationFn
? inputPreparationFn(model, opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you also need to add support for this in the different inputPreparationFns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, something like b366ee4 should allow to override all input options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants