initial import (#8361)

This commit is contained in:
David S. Batista 2024-09-13 17:24:19 +02:00 committed by GitHub
parent 57027c56fe
commit fbac1d8b04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()