__add__() — langchain Function Reference
Architecture documentation for the __add__() function in generation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e9282582_fda6_74d6_17f5_559cb69a82ba["__add__()"] 1a50ea5e_fdea_eab1_ba04_4c07083d74ef["GenerationChunk"] e9282582_fda6_74d6_17f5_559cb69a82ba -->|defined in| 1a50ea5e_fdea_eab1_ba04_4c07083d74ef style e9282582_fda6_74d6_17f5_559cb69a82ba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/outputs/generation.py lines 58–80
def __add__(self, other: GenerationChunk) -> GenerationChunk:
"""Concatenate two `GenerationChunk` objects.
Args:
other: Another `GenerationChunk` to concatenate with.
Raises:
TypeError: If other is not a `GenerationChunk`.
Returns:
A new `GenerationChunk` concatenated from self and other.
"""
if isinstance(other, GenerationChunk):
generation_info = merge_dicts(
self.generation_info or {},
other.generation_info or {},
)
return GenerationChunk(
text=self.text + other.text,
generation_info=generation_info or None,
)
msg = f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
raise TypeError(msg)
Domain
Subdomains
Source
Frequently Asked Questions
What does __add__() do?
__add__() is a function in the langchain codebase, defined in libs/core/langchain_core/outputs/generation.py.
Where is __add__() defined?
__add__() is defined in libs/core/langchain_core/outputs/generation.py at line 58.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free