fix: suppress LangChainDeprecationWarning messages (#4319)
* fix: suppress LangChainDeprecationWarning messages * fix: suppress LangChainDeprecationWarning messages
This commit is contained in:
parent
d38e79bde6
commit
80db2b92d2
3 changed files with 24 additions and 6 deletions
|
|
@ -1,3 +1,10 @@
|
|||
from .aiml import AIMLEmbeddingsImpl
|
||||
import warnings
|
||||
|
||||
from langchain_core._api.deprecation import LangChainDeprecationWarning
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", LangChainDeprecationWarning)
|
||||
from .aiml import AIMLEmbeddingsImpl
|
||||
|
||||
|
||||
__all__ = ["AIMLEmbeddingsImpl"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from .astradb import AstraDBToolComponent
|
||||
from .astradb_cql import AstraDBCQLToolComponent
|
||||
import warnings
|
||||
|
||||
from langchain_core._api.deprecation import LangChainDeprecationWarning
|
||||
|
||||
from .bing_search_api import BingSearchAPIComponent
|
||||
from .calculator import CalculatorToolComponent
|
||||
from .duck_duck_go_search_run import DuckDuckGoSearchComponent
|
||||
|
|
@ -17,6 +19,11 @@ from .wikipedia_api import WikipediaAPIComponent
|
|||
from .wolfram_alpha_api import WolframAlphaAPIComponent
|
||||
from .yahoo_finance import YfinanceToolComponent
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", LangChainDeprecationWarning)
|
||||
from .astradb import AstraDBToolComponent
|
||||
from .astradb_cql import AstraDBCQLToolComponent
|
||||
|
||||
__all__ = [
|
||||
"AstraDBCQLToolComponent",
|
||||
"AstraDBToolComponent",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import ast
|
||||
import contextlib
|
||||
import importlib
|
||||
import warnings
|
||||
from types import FunctionType
|
||||
from typing import Optional, Union
|
||||
|
||||
from langchain_core._api.deprecation import LangChainDeprecationWarning
|
||||
from loguru import logger
|
||||
from pydantic import ValidationError
|
||||
|
||||
|
|
@ -221,9 +223,11 @@ def prepare_global_scope(code, module):
|
|||
raise ModuleNotFoundError(msg) from e
|
||||
elif isinstance(node, ast.ImportFrom) and node.module is not None:
|
||||
try:
|
||||
imported_module = importlib.import_module(node.module)
|
||||
for alias in node.names:
|
||||
exec_globals[alias.name] = getattr(imported_module, alias.name)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", LangChainDeprecationWarning)
|
||||
imported_module = importlib.import_module(node.module)
|
||||
for alias in node.names:
|
||||
exec_globals[alias.name] = getattr(imported_module, alias.name)
|
||||
except ModuleNotFoundError as e:
|
||||
msg = f"Module {node.module} not found. Please install it and try again"
|
||||
raise ModuleNotFoundError(msg) from e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue