_function_annotations_are_pydantic_v1() — langchain Function Reference
Architecture documentation for the _function_annotations_are_pydantic_v1() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3a9d01e9_df14_0a93_ba4d_2e358386197e["_function_annotations_are_pydantic_v1()"] 6508e071_ac7c_8516_5d11_f42f8a45558c["base.py"] 3a9d01e9_df14_0a93_ba4d_2e358386197e -->|defined in| 6508e071_ac7c_8516_5d11_f42f8a45558c c0d52d58_8a26_451c_3602_695fe2854328["create_schema_from_function()"] c0d52d58_8a26_451c_3602_695fe2854328 -->|calls| 3a9d01e9_df14_0a93_ba4d_2e358386197e cbdab8cd_570e_b561_ecd4_9db77b54fe00["_is_pydantic_annotation()"] 3a9d01e9_df14_0a93_ba4d_2e358386197e -->|calls| cbdab8cd_570e_b561_ecd4_9db77b54fe00 style 3a9d01e9_df14_0a93_ba4d_2e358386197e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tools/base.py lines 247–276
def _function_annotations_are_pydantic_v1(
signature: inspect.Signature, func: Callable
) -> bool:
"""Check if all Pydantic annotations in a function are from v1.
Args:
signature: The function signature to check.
func: The function being checked.
Returns:
True if all Pydantic annotations are from v1, `False` otherwise.
Raises:
NotImplementedError: If the function contains mixed v1 and v2 annotations.
"""
any_v1_annotations = any(
_is_pydantic_annotation(parameter.annotation, pydantic_version="v1")
for parameter in signature.parameters.values()
)
any_v2_annotations = any(
_is_pydantic_annotation(parameter.annotation, pydantic_version="v2")
for parameter in signature.parameters.values()
)
if any_v1_annotations and any_v2_annotations:
msg = (
f"Function {func} contains a mix of Pydantic v1 and v2 annotations. "
"Only one version of Pydantic annotations per function is supported."
)
raise NotImplementedError(msg)
return any_v1_annotations and not any_v2_annotations
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _function_annotations_are_pydantic_v1() do?
_function_annotations_are_pydantic_v1() is a function in the langchain codebase, defined in libs/core/langchain_core/tools/base.py.
Where is _function_annotations_are_pydantic_v1() defined?
_function_annotations_are_pydantic_v1() is defined in libs/core/langchain_core/tools/base.py at line 247.
What does _function_annotations_are_pydantic_v1() call?
_function_annotations_are_pydantic_v1() calls 1 function(s): _is_pydantic_annotation.
What calls _function_annotations_are_pydantic_v1()?
_function_annotations_are_pydantic_v1() is called by 1 function(s): create_schema_from_function.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free