From 979b81864e147b33a7ab54ea19fc7ec822235d2d Mon Sep 17 00:00:00 2001 From: keenborder786 <21110290@lums.edu.pk> Date: Sun, 27 Apr 2025 04:03:58 +0500 Subject: [PATCH] [chore]: Move from inspect.siganture to model_fields.items() in get_all_basemodel_annotations --- libs/core/langchain_core/tools/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.py index daee8604307..8c25f2ce051 100644 --- a/libs/core/langchain_core/tools/base.py +++ b/libs/core/langchain_core/tools/base.py @@ -1078,7 +1078,7 @@ def get_all_basemodel_annotations( # cls has no subscript: cls = FooBar if isinstance(cls, type): annotations: dict[str, type] = {} - for name, param in inspect.signature(cls).parameters.items(): + for name, param in cls.model_fields.items(): # Exclude hidden init args added by pydantic Config. For example if # BaseModel(extra="allow") then "extra_data" will part of init sig. if ( @@ -1094,7 +1094,6 @@ def get_all_basemodel_annotations( get_origin(cls), default_to_bound=False ) orig_bases = (cls,) - # Pydantic v2 automatically resolves inherited generics, Pydantic v1 does not. if not (isinstance(cls, type) and is_pydantic_v2_subclass(cls)): # if cls = FooBar inherits from Baz[str], orig_bases will contain Baz[str]