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