Description
All three built-in retrievers implement __len__, but it is not part of the Retriever ABC, so generic code (if len(pipeline.retriever) == 0: ...) is not type-safe and third-party retrievers are not required to provide it. There is also no way to empty an index short of constructing a new retriever.
Acceptance criteria
Files to touch
ragframework/base.py
ragframework/retriever/in_memory.py, faiss.py, chroma.py
CONTRIBUTING.md
tests/test_retriever/*
Estimated effort: Small (< 2 hours)
Description
All three built-in retrievers implement
__len__, but it is not part of theRetrieverABC, so generic code (if len(pipeline.retriever) == 0: ...) is not type-safe and third-party retrievers are not required to provide it. There is also no way to empty an index short of constructing a new retriever.Acceptance criteria
Retriever.__len__(self) -> intdeclared@abstractmethodinragframework/base.pywith a docstring ("number of indexed chunks")Retriever.clear(self) -> Nonedeclared@abstractmethod; implemented inInMemoryRetriever(reset list + matrix),FAISSRetriever(drop index + dimension so the nextaddrebuilds),ChromaRetriever(delete + recreate the collection)CONTRIBUTING.md"Adding a New Integration" section updated to list the new required methodsclear()→len() == 0andretrieve()returns[]; re-addafter clear works (FAISS dimension may differ after clear)CHANGELOG.mdupdated under[Unreleased]→### Changed(note: breaking for third-partyRetrieversubclasses)Files to touch
ragframework/base.pyragframework/retriever/in_memory.py,faiss.py,chroma.pyCONTRIBUTING.mdtests/test_retriever/*Estimated effort: Small (< 2 hours)