Home / Function/ _remove_enum() — langchain Function Reference

_remove_enum() — langchain Function Reference

Architecture documentation for the _remove_enum() function in pydantic_utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  308f0879_d0aa_7d08_b310_9c1f1b32e7b1["_remove_enum()"]
  b22df862_b52d_14dc_cb85_6573258dd27c["pydantic_utils.py"]
  308f0879_d0aa_7d08_b310_9c1f1b32e7b1 -->|defined in| b22df862_b52d_14dc_cb85_6573258dd27c
  231942ec_e6ee_db67_4aa9_62b78c60b2f1["_schema()"]
  231942ec_e6ee_db67_4aa9_62b78c60b2f1 -->|calls| 308f0879_d0aa_7d08_b310_9c1f1b32e7b1
  31a96103_4c69_062c_4133_8d54d03d7cea["_normalize_schema()"]
  31a96103_4c69_062c_4133_8d54d03d7cea -->|calls| 308f0879_d0aa_7d08_b310_9c1f1b32e7b1
  style 308f0879_d0aa_7d08_b310_9c1f1b32e7b1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/pydantic_utils.py lines 60–73

def _remove_enum(obj: Any) -> None:
    """Remove the description from enums."""
    if isinstance(obj, dict):
        if "enum" in obj:
            if "description" in obj and obj["description"] == "An enumeration.":
                del obj["description"]
            if "type" in obj and obj["type"] == "string":
                del obj["type"]
            del obj["enum"]
        for value in obj.values():
            _remove_enum(value)
    elif isinstance(obj, list):
        for item in obj:
            _remove_enum(item)

Subdomains

Frequently Asked Questions

What does _remove_enum() do?
_remove_enum() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/pydantic_utils.py.
Where is _remove_enum() defined?
_remove_enum() is defined in libs/core/tests/unit_tests/pydantic_utils.py at line 60.
What calls _remove_enum()?
_remove_enum() is called by 2 function(s): _normalize_schema, _schema.

Analyze Your Own Codebase

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

Try Supermodel Free