`before_rabbithole_insert_memory`
Intervene before the RabbitHole insert a Document in the declarative memory.
Allows editing and enhancing a single Document before the RabbitHole add it to the declarative vector memory.
Example of the Langchain document:
doc = Document(page_content="So Long, and Thanks for All the Fish", metadata={})📄 Arguments
Section titled “📄 Arguments”| Name | Type | Description |
|---|---|---|
doc |
Document |
Langchain Document to be inserted in memory. |
cat |
Cat | Cheshire Cat instance, allows you to use the framework components. |
The Document has two properties:
page_content: the string with the text to save in memory;metadata: a dictionary with at least two keys:source: where the text comes from;when: timestamp to track when it’s been uploaded.
↩️ Return
Section titled “↩️ Return”Type: Document
Langchain Document that is added in the declarative vector memory.
✍ Example
Section titled “✍ Example”from cat.mad_hatter.decorators import hook
@hook # default priority = 1def before_rabbithole_insert_memory(doc, cat): # insert the user id metadata doc.metadata["user_id"] = cat.user_id
return doc