Home / Function/ _is_pydantic_annotation() — langchain Function Reference

_is_pydantic_annotation() — langchain Function Reference

Architecture documentation for the _is_pydantic_annotation() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  afc5c316_0bed_d543_09f0_01394541b54f["_is_pydantic_annotation()"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee["base.py"]
  afc5c316_0bed_d543_09f0_01394541b54f -->|defined in| 80cebff4_efbd_4311_85e9_de0dc81a7eee
  198ed473_bade_ca88_bf38_3399498f9947["_function_annotations_are_pydantic_v1()"]
  198ed473_bade_ca88_bf38_3399498f9947 -->|calls| afc5c316_0bed_d543_09f0_01394541b54f
  style afc5c316_0bed_d543_09f0_01394541b54f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tools/base.py lines 230–244

def _is_pydantic_annotation(annotation: Any, pydantic_version: str = "v2") -> bool:
    """Check if a type annotation is a Pydantic model.

    Args:
        annotation: The type annotation to check.
        pydantic_version: The Pydantic version to check against (`'v1'` or `'v2'`).

    Returns:
        `True` if the annotation is a Pydantic model, `False` otherwise.
    """
    base_model_class = BaseModelV1 if pydantic_version == "v1" else BaseModel
    try:
        return issubclass(annotation, base_model_class)
    except TypeError:
        return False

Subdomains

Frequently Asked Questions

What does _is_pydantic_annotation() do?
_is_pydantic_annotation() is a function in the langchain codebase, defined in libs/core/langchain_core/tools/base.py.
Where is _is_pydantic_annotation() defined?
_is_pydantic_annotation() is defined in libs/core/langchain_core/tools/base.py at line 230.
What calls _is_pydantic_annotation()?
_is_pydantic_annotation() is called by 1 function(s): _function_annotations_are_pydantic_v1.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free