Skip to content

after_rabbithole_splitted_text

Intervene after the RabbitHole has split the document in chunks.

Allows editing the list of Document right after the RabbitHole chunked them in smaller ones.

📄 Arguments

Name Type Description
chunks List[Document] List of Langchain Documents with text chunks.
cat StrayCat Cheshire Cat instance, allows you to use the framework components.

â†Šī¸ Return

Type: List[Document]

List of modified chunked Langchain Documents to be stored in the episodic memory.

✍ Example

from cat.mad_hatter.decorators import hook

@hook  # default priority = 1
def after_rabbithole_splitted_text(chunks, cat):
    # post process the chunks
    for chunk in chunks:
        new_content = cat.llm(f"Replace any dirty word with 'Meow': {chunk}")
        chunk.page_content = new_content

    return chunks