GenerationChunk Class — langchain Architecture
Architecture documentation for the GenerationChunk class in generation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb["GenerationChunk"] e24b5be2_a888_4700_a118_b05d34a03395["Generation"] ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb -->|extends| e24b5be2_a888_4700_a118_b05d34a03395 ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb["GenerationChunk"] ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb -->|extends| ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb f6b7d3d5_cc5d_7670_342a_fb0bc7ef1c38["generation.py"] ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb -->|defined in| f6b7d3d5_cc5d_7670_342a_fb0bc7ef1c38 934b918d_c045_bafa_0716_4414a3ba9c33["__add__()"] ed7dfa73_9b4e_fdd7_8c65_ba77c07d73fb -->|method| 934b918d_c045_bafa_0716_4414a3ba9c33
Relationship Graph
Source Code
libs/core/langchain_core/outputs/generation.py lines 55–80
class GenerationChunk(Generation):
"""`GenerationChunk`, which can be concatenated with other `Generation` chunks."""
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)
Extends
Source
Frequently Asked Questions
What is the GenerationChunk class?
GenerationChunk is a class in the langchain codebase, defined in libs/core/langchain_core/outputs/generation.py.
Where is GenerationChunk defined?
GenerationChunk is defined in libs/core/langchain_core/outputs/generation.py at line 55.
What does GenerationChunk extend?
GenerationChunk extends Generation, GenerationChunk.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free