Skip to content

Commit c30844f

Browse files
authored
fix(core): use version agnostic get_fields (#33108)
Resolves a warning
1 parent c9eb3bd commit c30844f

File tree

1 file changed

+2
-3
lines changed
  • libs/core/langchain_core/tools

1 file changed

+2
-3
lines changed

libs/core/langchain_core/tools/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,7 @@ def get_all_basemodel_annotations(
13241324
"""
13251325
# cls has no subscript: cls = FooBar
13261326
if isinstance(cls, type):
1327-
# Gather pydantic field objects (v2: model_fields / v1: __fields__)
1328-
fields = getattr(cls, "model_fields", {}) or getattr(cls, "__fields__", {})
1327+
fields = get_fields(cls)
13291328
alias_map = {field.alias: name for name, field in fields.items() if field.alias}
13301329

13311330
annotations: dict[str, Union[type, TypeVar]] = {}
@@ -1402,7 +1401,7 @@ def _replace_type_vars(
14021401
if type_ in generic_map:
14031402
return generic_map[type_]
14041403
if default_to_bound:
1405-
return type_.__bound__ or Any
1404+
return type_.__bound__ if type_.__bound__ is not None else Any
14061405
return type_
14071406
if (origin := get_origin(type_)) and (args := get_args(type_)):
14081407
new_args = tuple(

0 commit comments

Comments
 (0)