From f4e7cb394fa55645a10fa53630ccfe86fd724a44 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Thu, 5 Sep 2024 18:23:48 -0400 Subject: [PATCH] core[patch]: Ignore pydantic deprecation warnings in validate_arguments (#26122) For now, we'll use the deprecation functionality which is present until pydantic 3. --- libs/core/langchain_core/tools/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.py index b9d23ae9206..3665bc634c6 100644 --- a/libs/core/langchain_core/tools/base.py +++ b/libs/core/langchain_core/tools/base.py @@ -31,6 +31,7 @@ from pydantic import ( BaseModel, ConfigDict, Field, + PydanticDeprecationWarning, SkipValidation, ValidationError, model_validator, @@ -207,7 +208,12 @@ def create_schema_from_function( A pydantic model with the same arguments as the function. """ # https://docs.pydantic.dev/latest/usage/validation_decorator/ - validated = validate_arguments(func, config=_SchemaConfig) # type: ignore + with warnings.catch_warnings(): + # We are using deprecated functionality here. + # This code should be re-written to simply construct a pydantic model + # using inspect.signature and create_model. + warnings.simplefilter("ignore", category=PydanticDeprecationWarning) + validated = validate_arguments(func, config=_SchemaConfig) # type: ignore sig = inspect.signature(func)