huggingface: handle image-text-to-text pipeline task (#31611)

**Description:** Allows for HuggingFacePipeline to handle
image-text-to-text pipeline
This commit is contained in:
Peter Schneider 2025-06-14 13:41:11 -07:00 committed by GitHub
parent 50f998a138
commit cecfec5efa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,7 @@ DEFAULT_TASK = "text-generation"
VALID_TASKS = (
"text2text-generation",
"text-generation",
"image-text-to-text",
"summarization",
"translation",
)
@ -38,8 +39,8 @@ class HuggingFacePipeline(BaseLLM):
To use, you should have the ``transformers`` python package installed.
Only supports `text-generation`, `text2text-generation`, `summarization` and
`translation` for now.
Only supports `text-generation`, `text2text-generation`, `image-text-to-text`,
`summarization` and `translation` for now.
Example using from_model_id:
.. code-block:: python
@ -327,6 +328,8 @@ class HuggingFacePipeline(BaseLLM):
text = response["generated_text"]
elif self.pipeline.task == "text2text-generation":
text = response["generated_text"]
elif self.pipeline.task == "image-text-to-text":
text = response["generated_text"]
elif self.pipeline.task == "summarization":
text = response["summary_text"]
elif self.pipeline.task in "translation":