-
Notifications
You must be signed in to change notification settings - Fork 308
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
[draft] Support providerModelId in inference snippets #1210
Conversation
@@ -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}>`; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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
andhuggingface_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.