community[minor]: import fix (#20995)

Issue: When the third-party package is not installed, whenever we need
to `pip install <package>` the ImportError is raised.
But sometimes, the `ValueError` or `ModuleNotFoundError` is raised. It
is bad for consistency.
Change: replaced the `ValueError` or `ModuleNotFoundError` with
`ImportError` when we raise an error with the `pip install <package>`
message.
Note: Ideally, we replace all `try: import... except... raise ... `with
helper functions like `import_aim` or just use the existing
[langchain_core.utils.utils.guard_import](https://api.python.langchain.com/en/latest/utils/langchain_core.utils.utils.guard_import.html#langchain_core.utils.utils.guard_import)
But it would be much bigger refactoring. @baskaryan Please, advice on
this.
This commit is contained in:
Leonid Ganeline
2024-04-29 07:32:50 -07:00
committed by GitHub
parent 2ddac9a7c3
commit dc7c06bc07
65 changed files with 103 additions and 103 deletions

View File

@@ -108,7 +108,7 @@ class WeightOnlyQuantPipeline(LLM):
from transformers import AutoTokenizer
from transformers import pipeline as hf_pipeline
except ImportError:
raise ValueError(
raise ImportError(
"Could not import transformers python package. "
"Please install it with `pip install transformers` "
"and `pip install intel-extension-for-transformers`."
@@ -154,7 +154,7 @@ class WeightOnlyQuantPipeline(LLM):
f"currently only {VALID_TASKS} are supported"
)
except ImportError as e:
raise ValueError(
raise ImportError(
f"Could not load the {task} model due to missing dependencies."
) from e