mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
core[patch]: make get_all_basemodel_annotations public (#27761)
This commit is contained in:
@@ -449,7 +449,7 @@ class ChildTool(BaseTool):
|
||||
def tool_call_schema(self) -> type[BaseModel]:
|
||||
full_schema = self.get_input_schema()
|
||||
fields = []
|
||||
for name, type_ in _get_all_basemodel_annotations(full_schema).items():
|
||||
for name, type_ in get_all_basemodel_annotations(full_schema).items():
|
||||
if not _is_injected_arg_type(type_):
|
||||
fields.append(name)
|
||||
return _create_subset_model(
|
||||
@@ -962,7 +962,7 @@ def _is_injected_arg_type(type_: type) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def _get_all_basemodel_annotations(
|
||||
def get_all_basemodel_annotations(
|
||||
cls: Union[TypeBaseModel, Any], *, default_to_bound: bool = True
|
||||
) -> dict[str, type]:
|
||||
# cls has no subscript: cls = FooBar
|
||||
@@ -980,7 +980,7 @@ def _get_all_basemodel_annotations(
|
||||
orig_bases: tuple = getattr(cls, "__orig_bases__", ())
|
||||
# cls has subscript: cls = FooBar[int]
|
||||
else:
|
||||
annotations = _get_all_basemodel_annotations(
|
||||
annotations = get_all_basemodel_annotations(
|
||||
get_origin(cls), default_to_bound=False
|
||||
)
|
||||
orig_bases = (cls,)
|
||||
@@ -994,7 +994,7 @@ def _get_all_basemodel_annotations(
|
||||
# if class = FooBar inherits from Baz, parent = Baz
|
||||
if isinstance(parent, type) and is_pydantic_v1_subclass(parent):
|
||||
annotations.update(
|
||||
_get_all_basemodel_annotations(parent, default_to_bound=False)
|
||||
get_all_basemodel_annotations(parent, default_to_bound=False)
|
||||
)
|
||||
continue
|
||||
|
||||
|
Reference in New Issue
Block a user