From cecfec5efa325fcb932354e870c00c17d1c754d9 Mon Sep 17 00:00:00 2001 From: Peter Schneider Date: Sat, 14 Jun 2025 13:41:11 -0700 Subject: [PATCH] huggingface: handle image-text-to-text pipeline task (#31611) **Description:** Allows for HuggingFacePipeline to handle image-text-to-text pipeline --- .../langchain_huggingface/llms/huggingface_pipeline.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py b/libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py index 96e408bb7a4..858aa92676c 100644 --- a/libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py +++ b/libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py @@ -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":