Skip to content

Use Hugging Face HTTP API to determine task types #14

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 1 commit into
base: main
Choose a base branch
from

Conversation

zeke
Copy link
Member

@zeke zeke commented May 5, 2025

Every model on HF is guaranteed to have a task type.

As such, our current models.ts mappings don't need to have a manually entered task type:

{
  hfModel: "black-forest-labs/FLUX.1-dev",
  providerModel: "black-forest-labs/flux-dev",
  type: 'text-to-image`
}

Instead we can omit the type from the human-generated mapping:

{
  hfModel: "black-forest-labs/FLUX.1-dev",
  providerModel: "black-forest-labs/flux-dev"
}

... then use the Hugging Face HTTP API to fetch the Task™ (aka pipeline_tag) for each model.

This PR hits the API for each model, attaches the tasks to each model object, then hits the HF Model Mappings API.

@zeke zeke requested review from fofr, lucataco, zsxkib and a team May 5, 2025 23:05
@zeke
Copy link
Member Author

zeke commented May 5, 2025

Copy link

@julien-c julien-c left a comment

Choose a reason for hiding this comment

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

lgtm conceptually!

// e.g. "text-to-image", "image-to-image", "text-to-video", etc.
const getModelTask = async (model: InferenceModel) => {
const response = await fetch(`https://huggingface.co/api/models/${model.hfModel}`);
const data = await response.json() as { pipeline_tag: string };
Copy link

Choose a reason for hiding this comment

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

can potentially be undefined (but should be rare)

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