Skip to content
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

[draft] Support providerModelId in inference snippets #1210

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Feb 19, 2025

Goal of this PR is to correctly handle model id mapping when generating inference snippets for a given provider.

For now it's a simple PR to showcase what I had in mind in https://github.com/huggingface-internal/moon-landing/pull/12626#discussion_r1961923510 (private repo). I only implemented it for chat-completion curl snippet but the rest would follow the same pattern.

Note that we should use the mapping "only" for curl, pure Python, pure JS and openai client snippets. For huggingface.js and huggingface_hub ones, the model id from the Hub should be used.


Note: orthogonal to this PR but I realized that some URLs are also incorrect depending on the provider.

@SBrandeis SBrandeis marked this pull request as ready for review February 20, 2025 16:30
@SBrandeis SBrandeis merged commit f931db2 into main Feb 20, 2025
5 checks passed
@SBrandeis SBrandeis deleted the support-provider-model-id-in-inference-snippets branch February 20, 2025 16:52
@@ -133,7 +133,8 @@ function generateInferenceSnippet(
provider: SnippetInferenceProvider,
opts?: Record<string, unknown>
): InferenceSnippet[] {
return GET_SNIPPET_FN[language](model, "api_token", provider, opts);
const providerModelId = provider === "hf-inference" ? model.id : `<${provider} alias for ${model.id}>`;
Copy link
Member

Choose a reason for hiding this comment

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

this is neat, i like it^

opts?: Record<string, unknown>
): InferenceSnippet[] {
if (model.tags.includes("conversational")) {
// Conversational model detected, so we display a code snippet that features the Messages API
return snippetConversational(model, accessToken, provider, opts);
return snippetConversational(model, accessToken, provider, providerModelId, opts);
Copy link
Member

Choose a reason for hiding this comment

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

in theory given model and provider, then providerModelId is unneeded/redundant, because model contains the provider mapping.

But in practice it's probably simpler to do it explicitly like that

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.

3 participants