mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
Replaced instances of raising ValueError with raising ImportError. (#9388)
Refactored code to ensure consistent handling of ImportError. Replaced instances of raising ValueError with raising ImportError. The choice of raising a ValueError here is somewhat unconventional and might lead to confusion for anyone reading the code. Typically, when dealing with import-related errors, the recommended approach is to raise an ImportError with a descriptive message explaining the issue. This provides a clearer indication that the problem is related to importing the required module. @hwchase17 , @baskaryan , @eyurtsev Thanks Aashish --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
0c4683ebcc
commit
ce78877a87
@ -149,7 +149,7 @@ class HuggingFaceInstructEmbeddings(BaseModel, Embeddings):
|
||||
self.model_name, cache_folder=self.cache_folder, **self.model_kwargs
|
||||
)
|
||||
except ImportError as e:
|
||||
raise ValueError("Dependencies for InstructorEmbedding not found.") from e
|
||||
raise ImportError("Dependencies for InstructorEmbedding not found.") from e
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
|
@ -30,7 +30,7 @@ class DuckDuckGoSearchAPIWrapper(BaseModel):
|
||||
try:
|
||||
from duckduckgo_search import DDGS # noqa: F401
|
||||
except ImportError:
|
||||
raise ValueError(
|
||||
raise ImportError(
|
||||
"Could not import duckduckgo-search python package. "
|
||||
"Please install it with `pip install duckduckgo-search`."
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user