Handle hf_inference in single file #2766
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cc @hanouticelina this is a suggestion for PR #2757
Main changes are:
provider_helper.prepare_payload
should not have aexpect_binary
parameter => since theprovider_helper
depends on the task, we already know if the input must be a binary or notmodel: Optional[str]
required inprovider_helper.prepare_payload
for all providers and all tasks. At the moment themodel
is only passed if we know the provider will use it. But in practice theInferenceClient
and providers implementation should be independent. Hence passing it all the time and letting the provider decide what to do with the info.hf-inference
provider. This reduces by a lot the complexity / duplicated code. I'm definingHfInferenceTask
for generic tasks,HFInferenceBinaryInputTask
for tasks which require a binary input (so no need forexpect_binary: bool
anymore) andHFInferenceConversational
for specific task.Let me know what you think. We can either discuss some changes here or merge it and continue on your PR.