LlamaIndex integration
Astrocyte as a memory store for LlamaIndex agents and chat engines.
Module: astrocyte.integrations.llamaindex
Pattern: Memory store — put, get, get_all, search, reset
Framework dependency: llama-index-core (optional)
Install
Section titled “Install”pip install astrocyte llama-index-corefrom astrocyte import Astrocytefrom astrocyte.integrations.llamaindex import AstrocyteLlamaMemory
brain = Astrocyte.from_config("astrocyte.yaml")memory = AstrocyteLlamaMemory(brain, bank_id="user-123", max_results=10)
# Store and retrieveawait memory.put("Calvin prefers dark mode", tags=["preference"])context = await memory.get("UI preferences")# → "- Calvin prefers dark mode"
# Get all memories in the bankall_mems = await memory.get_all()
# Structured searchresults = await memory.search("dark mode", tags=["preference"])
# Reset bankawait memory.reset()Integration pattern
Section titled “Integration pattern”| LlamaIndex method | Astrocyte call |
|---|---|
put(content) | brain.retain() → returns memory_id |
get(query) | brain.recall() → formatted string for prompts |
get_all() | brain.recall("*") → all memories as dicts |
search(query) | brain.recall() → structured hit dicts |
reset() | brain.forget(scope="all") |
API reference
Section titled “API reference”AstrocyteLlamaMemory(brain, bank_id, *, max_results=10)
Section titled “AstrocyteLlamaMemory(brain, bank_id, *, max_results=10)”| Method | Returns |
|---|---|
put(content, *, tags=None, metadata=None) | str | None (memory_id) |
get(query, *, max_results=None) | str (formatted context) |
get_all() | list[dict] |
search(query, *, max_results=None, tags=None) | list[dict] |
reset() | None |