-
Notifications
You must be signed in to change notification settings - Fork 779
fix: update payload preparation to merge parameters into the output dictionary #3160
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
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Hey @mishig25 , thanks for reporting + opened a PR. I just pushed 889a4ee so that this fix applies only to "feature-extraction"
task and not to all tasks. I also added a quick test.
I'm approving right now but if that's fine with you, I'd prefer to wait until @hanouticelina 's back to have her opinion as well.
Note: I went back to our input.json specs which clearly states that parameters must be at root level.
src/huggingface_hub/__init__.py
Outdated
@@ -46,7 +46,7 @@ | |||
from typing import TYPE_CHECKING | |||
|
|||
|
|||
__version__ = "0.33.0.dev0" | |||
__version__ = "0.33.0" |
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.
no need for this change 50dba39
__version__ = "0.33.0" | |
__version__ = "0.33.0.dev0" |
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.
I need it in the meantime. Otherwise, getting error when using with diffusers: version has to be xyz
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.
ah yes ok so let's not forget about it before merging. Converting back to draft in the meantime
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.
Looks good to me! let's move this PR to ready for review and revert the package version change before merging. Once it's merged, we can go ahead and release a patch.
Side note: This also got me thinking that we should probably consider switch now to OpenAI-compatible specs for embeddings/feature-extraction for HF Inference API and update the SDKs accordingly (in another PRs of course!). cc @tomaarsen for viz
actually, when I try after @Wauplin changes, I'm getting the error of parameters being ignored |
@mishig25 what is the exact error you're getting? with this PR, the following snippet works as expected and truncate is sent at the root level: from huggingface_hub import InferenceClient
client = InferenceClient(base_url="MY_INFERENCE_ENDPOINT_URL", token="hf_TOKEN")
embeddings = client.feature_extraction("This is a test sentence. "*100, truncate=True)
print(embeddings) |
This reverts commit 50dba39.
@hanouticelina it is working now, will merge it |
…ictionary (#3160) * fix: update payload preparation to merge parameters into the output dictionary * dev change * Update only feature-extraction task + add test + add specs link * [dev change] * Revert "[dev change]" This reverts commit 50dba39. --------- Co-authored-by: Lucain Pouget <[email protected]>
…ictionary (huggingface#3160) * fix: update payload preparation to merge parameters into the output dictionary * dev change * Update only feature-extraction task + add test + add specs link * [dev change] * Revert "[dev change]" This reverts commit 50dba39. --------- Co-authored-by: Lucain Pouget <[email protected]>
Fix feature extraction parameter structure for Inference Endpoints compatibility
Problem
The
feature_extraction
method'struncate
parameter (and other parameters likenormalize
,prompt_name
,truncation_direction
) is not working correctly when using custom InferenceEndpoints via
base_url
.Root Cause
When the provider helper system was introduced in #2777, the parameter structure for HF
Inference API requests was inadvertently changed from root-level parameters to nested
parameters:
Before (working):
After #2777 (broken):
Impact
This inconsistency breaks existing Inference Endpoints that were deployed expecting the
original parameter format.
Solution
Restore the original parameter structure by modifying
HFInferenceTask._prepare_payload_as_dict() to place parameters at the root level instead of
nesting them under a "parameters" key.
Fixed payload:
Testing
Without this PR, the snippet below fails: