Home / Function/ __add__() — langchain Function Reference

__add__() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  5e6d8db7_c11d_e62d_4ba1_d612fb464849["__add__()"]
  abb7c122_ee7b_4c8f_ffaa_3d3d63c4fab7["BaseMessage"]
  5e6d8db7_c11d_e62d_4ba1_d612fb464849 -->|defined in| abb7c122_ee7b_4c8f_ffaa_3d3d63c4fab7
  style 5e6d8db7_c11d_e62d_4ba1_d612fb464849 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/base.py lines 294–307

    def __add__(self, other: Any) -> ChatPromptTemplate:
        """Concatenate this message with another message.

        Args:
            other: Another message to concatenate with this one.

        Returns:
            A ChatPromptTemplate containing both messages.
        """
        # Import locally to prevent circular imports.
        from langchain_core.prompts.chat import ChatPromptTemplate  # noqa: PLC0415

        prompt = ChatPromptTemplate(messages=[self])
        return prompt.__add__(other)

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free