update sentence transformers import error message (#7906)

This commit is contained in:
Stefano Fiorucci 2024-06-20 18:15:01 +02:00 committed by GitHub
parent 4c59000c21
commit d80e01492b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 4 deletions

View File

@ -9,7 +9,7 @@ import numpy as np
from haystack.lazy_imports import LazyImport
from haystack.utils.auth import Secret
with LazyImport(message="Run 'pip install \"sentence-transformers>=2.2.0\"'") as sentence_transformers_import:
with LazyImport(message="Run 'pip install \"sentence-transformers>=2.3.0\"'") as sentence_transformers_import:
from sentence_transformers import SentenceTransformer

View File

@ -11,7 +11,7 @@ from haystack.lazy_imports import LazyImport
from haystack.utils import ComponentDevice, expit
from haystack.utils.auth import Secret, deserialize_secrets_inplace
with LazyImport(message="Run 'pip install scikit-learn \"sentence-transformers>=2.2.0\"'") as sas_import:
with LazyImport(message="Run 'pip install \"sentence-transformers>=2.3.0\"'") as sas_import:
from sentence_transformers import CrossEncoder, SentenceTransformer, util
from transformers import AutoConfig

View File

@ -11,7 +11,7 @@ from haystack.utils import ComponentDevice, Secret, deserialize_secrets_inplace
logger = logging.getLogger(__name__)
with LazyImport(message="Run 'pip install \"sentence-transformers>=2.2.0\"'") as torch_and_sentence_transformers_import:
with LazyImport(message="Run 'pip install \"sentence-transformers>=2.3.0\"'") as torch_and_sentence_transformers_import:
import torch
from sentence_transformers import SentenceTransformer

View File

@ -79,7 +79,7 @@ format-check = "ruff format --check {args}"
extra-dependencies = [
"transformers[torch,sentencepiece]==4.41.2", # ExtractiveReader, TransformersSimilarityRanker, LocalWhisperTranscriber, HFGenerators...
"huggingface_hub>=0.23.0", # Hugging Face API Generators and Embedders
"sentence-transformers>=2.2.0", # SentenceTransformersTextEmbedder and SentenceTransformersDocumentEmbedder
"sentence-transformers>=2.3.0", # SentenceTransformersTextEmbedder and SentenceTransformersDocumentEmbedder
"langdetect", # TextLanguageRouter and DocumentLanguageClassifier
"openai-whisper>=20231106", # LocalWhisperTranscriber

View File

@ -0,0 +1,5 @@
---
enhancements:
- |
Update the error message when the `sentence-transformers` library is not installed
and the used component requires it.