Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/huggingface_inference_toolkit/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
inputs = data.pop("inputs", data)
parameters = data.pop("parameters", {})

# sentence transformers pipelines do not have the `task` arg
if any(isinstance(self.pipeline, v) for v in SENTENCE_TRANSFORMERS_TASKS.values()):
return self.pipeline(**inputs) if isinstance(inputs, dict) else self.pipeline(inputs) # type: ignore
# diffusers and sentence transformers pipelines do not have the `task` arg
if not hasattr(self.pipeline, "task"):
# sentence transformers paramters not supported yet
if any(isinstance(self.pipeline, v) for v in SENTENCE_TRANSFORMERS_TASKS.values()):
return ( # type: ignore
self.pipeline(**inputs) if isinstance(inputs, dict) else self.pipeline(inputs)
)
# diffusers does support kwargs
return ( # type: ignore
self.pipeline(**inputs, **parameters)
if isinstance(inputs, dict)
else self.pipeline(inputs, **parameters)
)

if self.pipeline.task == "question-answering":
if not isinstance(inputs, dict):
Expand Down
Loading