diff --git a/haystack/components/extractors/named_entity_extractor.py b/haystack/components/extractors/named_entity_extractor.py index bfd5e0dbc..00350e6ae 100644 --- a/haystack/components/extractors/named_entity_extractor.py +++ b/haystack/components/extractors/named_entity_extractor.py @@ -12,7 +12,7 @@ from haystack import ComponentError, DeserializationError, Document, component, from haystack.lazy_imports import LazyImport from haystack.utils.device import ComponentDevice -with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import: +with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import: from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline from transformers import Pipeline as HfPipeline diff --git a/haystack/components/generators/chat/hugging_face_local.py b/haystack/components/generators/chat/hugging_face_local.py index 2f43f8d18..419fde20b 100644 --- a/haystack/components/generators/chat/hugging_face_local.py +++ b/haystack/components/generators/chat/hugging_face_local.py @@ -18,7 +18,7 @@ from haystack.utils import ( logger = logging.getLogger(__name__) -with LazyImport(message="Run 'pip install transformers[torch]'") as torch_and_transformers_import: +with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as torch_and_transformers_import: from huggingface_hub import model_info from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast, StoppingCriteriaList, pipeline diff --git a/haystack/components/generators/hugging_face_local.py b/haystack/components/generators/hugging_face_local.py index 59561256f..178548c61 100644 --- a/haystack/components/generators/hugging_face_local.py +++ b/haystack/components/generators/hugging_face_local.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) SUPPORTED_TASKS = ["text-generation", "text2text-generation"] -with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import: +with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import: from transformers import StoppingCriteriaList, pipeline from haystack.utils.hf import ( # pylint: disable=ungrouped-imports diff --git a/haystack/utils/device.py b/haystack/utils/device.py index 517cb0461..ab635184e 100644 --- a/haystack/utils/device.py +++ b/haystack/utils/device.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) with LazyImport( message="PyTorch must be installed to use torch.device or use GPU support in HuggingFace transformers. " - "Run 'pip install transformers[torch]'" + "Run 'pip install \"transformers[torch]\"'" ) as torch_import: import torch diff --git a/haystack/utils/hf.py b/haystack/utils/hf.py index f527b2431..89f036a70 100644 --- a/haystack/utils/hf.py +++ b/haystack/utils/hf.py @@ -13,7 +13,7 @@ from haystack.lazy_imports import LazyImport from haystack.utils.auth import Secret from haystack.utils.device import ComponentDevice -with LazyImport(message="Run 'pip install transformers[torch]'") as torch_import: +with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as torch_import: import torch with LazyImport(message="Run 'pip install \"huggingface_hub>=0.23.0\"'") as huggingface_hub_import: @@ -270,7 +270,7 @@ def check_generation_params(kwargs: Optional[Dict[str, Any]], additional_accepte ) -with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import: +with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import: from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast, StoppingCriteria, TextStreamer torch_import.check()