Home / Function/ _get_type() — langchain Function Reference

_get_type() — langchain Function Reference

Architecture documentation for the _get_type() function in utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4ee435e6_3e55_0624_2bea_4d0947834ed5["_get_type()"]
  0b528c80_0ce7_1c74_8932_bc433bcb03c6["utils.py"]
  4ee435e6_3e55_0624_2bea_4d0947834ed5 -->|defined in| 0b528c80_0ce7_1c74_8932_bc433bcb03c6
  style 4ee435e6_3e55_0624_2bea_4d0947834ed5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/utils.py lines 68–83

def _get_type(v: Any) -> str:
    """Get the type associated with the object for serialization purposes."""
    if isinstance(v, dict) and "type" in v:
        result = v["type"]
    elif hasattr(v, "type"):
        result = v.type
    else:
        msg = (
            f"Expected either a dictionary with a 'type' key or an object "
            f"with a 'type' attribute. Instead got type {type(v)}."
        )
        raise TypeError(msg)
    if not isinstance(result, str):
        msg = f"Expected 'type' to be a str, got {type(result).__name__}"
        raise TypeError(msg)
    return result

Subdomains

Frequently Asked Questions

What does _get_type() do?
_get_type() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/utils.py.
Where is _get_type() defined?
_get_type() is defined in libs/core/langchain_core/messages/utils.py at line 68.

Analyze Your Own Codebase

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

Try Supermodel Free