deepset-ai / deepset-ai/haystack
Components expecting `List[...]` input should use `Iterable[...]` instead
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 26.6k
- Forks
- 3.2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 194
Description
For example, let's say I have a generator that yields my documents:
def get_documents():
for some_thing in some_other_generator():
yield some_thing
If I try to use the OpenAIDocumentEmbedder with this, I get an error that I must use a list. Therefore I am forced to exhaust the python generator and load all documents into memory.
Many components in the haystack library require List when an Iterable would do just fine. For example, OpenAIDocumentEmbedder could be updated to use python generators instead of raw lists, making the process more memory effecitent.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the OpenAIDocumentEmbedder input handling and identify the other components that require List inputs. Check how generator inputs are validated or consumed, then verify that supported Iterable inputs are not eagerly loaded into memory and that the existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100