Skip to content

Commit a438b8d

Browse files
Skip provider/task combos with no @huggingface/inference snippet helper (#2527)
The inference-providers doc build prerenders an <InferenceSnippet> for every (provider, task) section. The doc-builder generates those snippets via @huggingface/inference's getProviderHelper(provider, task), which throws an InferenceClientInputError when the provider has no helper for that task. The uncaught error surfaces as a SvelteKit 500 and fails the whole build. This happens whenever a provider's partner API advertises a live model for a task that @huggingface/inference doesn't (yet) support as a snippet, e.g. `together` + `automatic-speech-recognition` (added in #2507), which has been breaking the inference-providers doc build on main since 2026-05-29. Guard generate.ts so it never emits such a section: mirror the doc-builder's helper lookup (resolving conversational text-generation / image-text-to-text to the "conversational" task) and skip any combo getProviderHelper can't handle. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e00769f commit a438b8d

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

scripts/inference-providers/scripts/generate.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PipelineType } from "@huggingface/tasks";
2-
import { PROVIDERS_HUB_ORGS } from "@huggingface/inference";
2+
import { PROVIDERS_HUB_ORGS, getProviderHelper } from "@huggingface/inference";
33
import Handlebars from "handlebars";
44
import * as fs from "node:fs/promises";
55
import * as path from "node:path/posix";
@@ -478,6 +478,19 @@ await Promise.all(
478478
}),
479479
);
480480

481+
/// A provider may serve a live model for a task that `@huggingface/inference`
482+
/// has no snippet helper for. Emitting an `<InferenceSnippet>` for such a combo
483+
/// crashes the doc-builder prerender (`getProviderHelper` throws), so we mirror
484+
/// that lookup here and skip any (provider, task) combo it can't handle.
485+
function isSnippetSupported(provider: string, task: string): boolean {
486+
try {
487+
getProviderHelper(provider, task);
488+
return true;
489+
} catch {
490+
return false;
491+
}
492+
}
493+
481494
async function fetchWarmModels(
482495
task: PipelineType,
483496
conversational: boolean = false,
@@ -498,9 +511,18 @@ async function fetchWarmModels(
498511
]
499512
: ["hf-inference", ...(PER_TASK_SUPPORTED_PROVIDERS[task] ?? [])]
500513
).sort();
514+
// The doc-builder resolves conversational text-generation / image-text-to-text
515+
// snippets to the "conversational" helper task; mirror that here.
516+
const helperTask = conversational ? "conversational" : task;
501517
return (
502518
await Promise.all(
503519
providers.map(async (provider) => {
520+
if (!isSnippetSupported(provider, helperTask)) {
521+
console.warn(
522+
` ⏭️ Skipping ${provider} for ${task}: @huggingface/inference has no snippet helper for this (provider, task) combo`,
523+
);
524+
return;
525+
}
504526
console.log(
505527
` ⚡ Fetching most popular warm model for ${task} from ${provider}`,
506528
);

0 commit comments

Comments
 (0)