Home / Function/ __setattr__() — langchain Function Reference

__setattr__() — langchain Function Reference

Architecture documentation for the __setattr__() function in types.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  908b36dd_dc6d_a5b3_4e91_fb69f2583c51["__setattr__()"]
  f413466f_6fee_56c2_0df7_03cfa4e2b92a["ModelRequest"]
  908b36dd_dc6d_a5b3_4e91_fb69f2583c51 -->|defined in| f413466f_6fee_56c2_0df7_03cfa4e2b92a
  e2585731_77e3_b7bd_6c0a_772b884fe839["override()"]
  908b36dd_dc6d_a5b3_4e91_fb69f2583c51 -->|calls| e2585731_77e3_b7bd_6c0a_772b884fe839
  style 908b36dd_dc6d_a5b3_4e91_fb69f2583c51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/types.py lines 168–200

    def __setattr__(self, name: str, value: Any) -> None:
        """Set an attribute with a deprecation warning.

        Direct attribute assignment on `ModelRequest` is deprecated. Use the
        `override()` method instead to create a new request with modified attributes.

        Args:
            name: Attribute name.
            value: Attribute value.
        """
        # Special handling for system_prompt - convert to system_message
        if name == "system_prompt":
            warnings.warn(
                "Direct attribute assignment to ModelRequest.system_prompt is deprecated. "
                "Use request.override(system_message=SystemMessage(...)) instead to create "
                "a new request with the modified system message.",
                DeprecationWarning,
                stacklevel=2,
            )
            if value is None:
                object.__setattr__(self, "system_message", None)
            else:
                object.__setattr__(self, "system_message", SystemMessage(content=value))
            return

        warnings.warn(
            f"Direct attribute assignment to ModelRequest.{name} is deprecated. "
            f"Use request.override({name}=...) instead to create a new request "
            f"with the modified attribute.",
            DeprecationWarning,
            stacklevel=2,
        )
        object.__setattr__(self, name, value)

Domain

Subdomains

Calls

Frequently Asked Questions

What does __setattr__() do?
__setattr__() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/types.py.
Where is __setattr__() defined?
__setattr__() is defined in libs/langchain_v1/langchain/agents/middleware/types.py at line 168.
What does __setattr__() call?
__setattr__() calls 1 function(s): override.

Analyze Your Own Codebase

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

Try Supermodel Free