Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues
ListJoiner
Component to Merge Multiple Lists into a Single List #8714Proposed Changes:
This PR adds a new ListJoiner component that allows merging multiple lists into a single flat list while preserving the order of inputs. This is particularly useful for scenarios where multiple List[ChatMessage] need to be consolidated into one unified list.
Changes
Add ListJoiner component in haystack/components/joiners/list_joiner.py
Add comprehensive test suite in test/components/joiners/test_list_joiner.py
Key Features
Generic implementation that works with any list type (e.g., List[ChatMessage], List[int], etc.)
Preserves input order (earlier inputs appear first in the output)
Simple interface that works with Haystack's Pipeline
Type-safe implementation using Python's generics
Example usage with ChatMessages:
from haystack import Pipeline
from haystack.dataclasses import ChatMessage
from haystack.components.joiners import ListJoiner
messages1 = [ChatMessage.from_user("Hello"), ChatMessage.from_assistant("Hi there")]
messages2 = [ChatMessage.from_user("How are you?")]
p = Pipeline()
p.add_component("joiner", ListJoiner())
result = p.run(data={"lists": [messages1, messages2]})
result.messages will be [messages1[0], messages1[1], messages2[0]]
How did you test it?
The test suite checks:
Empty list handling
Single list input
Multiple list inputs
ChatMessage list handling
Pipeline integration
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.