Home / Function/ __add__() — langchain Function Reference

__add__() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4b5c1227_679d_ca31_6ed5_c01613c6fb73["__add__()"]
  b29d7e0a_6e97_8a9f_6b67_717670e94c07["FunctionMessageChunk"]
  4b5c1227_679d_ca31_6ed5_c01613c6fb73 -->|defined in| b29d7e0a_6e97_8a9f_6b67_717670e94c07
  style 4b5c1227_679d_ca31_6ed5_c01613c6fb73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/function.py lines 44–62

    def __add__(self, other: Any) -> BaseMessageChunk:  # type: ignore[override]
        if isinstance(other, FunctionMessageChunk):
            if self.name != other.name:
                msg = "Cannot concatenate FunctionMessageChunks with different names."
                raise ValueError(msg)

            return self.__class__(
                name=self.name,
                content=merge_content(self.content, other.content),
                additional_kwargs=merge_dicts(
                    self.additional_kwargs, other.additional_kwargs
                ),
                response_metadata=merge_dicts(
                    self.response_metadata, other.response_metadata
                ),
                id=self.id,
            )

        return super().__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/function.py.
Where is __add__() defined?
__add__() is defined in libs/core/langchain_core/messages/function.py at line 44.

Analyze Your Own Codebase

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

Try Supermodel Free