Skip to content

[InferenceSnippet] do not fail entirely if snippets did not work #574

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

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jun 18, 2025

Currently doc-builder fails on Inference Provider docs with:

(taken from PR huggingface/hub-docs#1788 / see CI here)

Failed to get provider helper for replicate (automatic-speech-recognition) InferenceClientInputError: Task 'automatic-speech-recognition' not supported for provider 'replicate'. Available tasks: text-to-image,text-to-speech,text-to-video

This is due to provider Replicate having a automatic-speech-recognition model listed even though the JS / Python clients do not support it (and therefore we cannot generate the snippets). Instead of failing entirely it would be best to warn on error and continue. This allows other snippets to be correctly updated.


Note: a solution in parallel is to unlist the failing model on Replicate side. I already pinged them on Slack about that but in any case, we should not block doc updates just because of a mistake from a provider.

@Wauplin Wauplin requested review from mishig25 and Copilot June 18, 2025 09:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that errors during inference snippet generation do not block documentation updates by catching exceptions and returning empty snippets. Key changes include:

  • Adding a new interface (InferenceProviderMappingEntry) to support mapping information.
  • Creating a helper function (getInferenceSnippetsOrEmpty) that wraps snippet retrieval in a try-catch.
  • Updating code calls to use the new helper function, preventing complete failure on snippet generation failures.
Comments suppressed due to low confidence (1)

kit/src/lib/InferenceSnippet/InferenceSnippet.svelte:76

  • Add a brief comment explaining the purpose of getInferenceSnippetsOrEmpty(), particularly why errors are caught and an empty array is returned.
	function getInferenceSnippetsOrEmpty(

Wauplin added a commit to huggingface/huggingface.js that referenced this pull request Jun 18, 2025
Currently `InferenceProviderMappingEntry` is defined in a module that is
not exported. This PR moves it to the `types.ts` module for better
reusability (will be useful for
huggingface/doc-builder#574 (comment))
@Wauplin
Copy link
Contributor Author

Wauplin commented Jun 18, 2025

@mishig25 PR is ready for review

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.

1 participant