Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
reorder.py18 linesDownload Raw Back to data_post_processor
1from core.rag.models.document import Document2 3 4class ReorderRunner:5    def run(self, documents: list[Document]) -> list[Document]:6        # Retrieve elements from odd indices (0, 2, 4, etc.) of the documents list7        odd_elements = documents[::2]8 9        # Retrieve elements from even indices (1, 3, 5, etc.) of the documents list10        even_elements = documents[1::2]11 12        # Reverse the list of elements from even indices13        even_elements_reversed = even_elements[::-1]14 15        new_documents = odd_elements + even_elements_reversed16 17        return new_documents18