__add__() — langchain Function Reference
Architecture documentation for the __add__() function in tool.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d9ce065e_81b3_cfb3_689b_ec7c267f9c54["__add__()"] b948836a_8972_401c_7898_c83f3d6bf485["ToolMessageChunk"] d9ce065e_81b3_cfb3_689b_ec7c267f9c54 -->|defined in| b948836a_8972_401c_7898_c83f3d6bf485 a8e116d1_b854_7d71_8ff6_e9ffa7f10e75["_merge_status()"] d9ce065e_81b3_cfb3_689b_ec7c267f9c54 -->|calls| a8e116d1_b854_7d71_8ff6_e9ffa7f10e75 style d9ce065e_81b3_cfb3_689b_ec7c267f9c54 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/tool.py lines 183–203
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore[override]
if isinstance(other, ToolMessageChunk):
if self.tool_call_id != other.tool_call_id:
msg = "Cannot concatenate ToolMessageChunks with different names."
raise ValueError(msg)
return self.__class__(
tool_call_id=self.tool_call_id,
content=merge_content(self.content, other.content),
artifact=merge_obj(self.artifact, other.artifact),
additional_kwargs=merge_dicts(
self.additional_kwargs, other.additional_kwargs
),
response_metadata=merge_dicts(
self.response_metadata, other.response_metadata
),
id=self.id,
status=_merge_status(self.status, other.status),
)
return super().__add__(other)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does __add__() do?
__add__() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/tool.py.
Where is __add__() defined?
__add__() is defined in libs/core/langchain_core/messages/tool.py at line 183.
What does __add__() call?
__add__() calls 1 function(s): _merge_status.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free