Fetch the complete documentation index at: https://docs.mem0.ai/llms.txt Use this file to discover all available pages before exploring further.
Integrate Neocortex with Pipecat to add long‑term conversational memory to your voice and chat agents.
This package provides a NeocortexMemoryService that plugs into the Pipecat pipeline in the same way as Mem0MemoryService, but stores and retrieves memories from Neocortex instead.
Install from your workspace (or virtualenv) that runs Pipecat:
pip install neocortex-pipecatYou will also need to set your Neocortex API key as an environment variable:
export TINYHUMANS_API_KEY=your_neocortex_api_keyOptionally, configure a custom Neocortex base URL:
export TINYHUMANS_BASE_URL=https://api.your-backend.comNeocortex integration is provided through the NeocortexMemoryService class.
from neocortex_pipecat import NeocortexMemoryService, NeocortexParams
memory = NeocortexMemoryService(
api_key=os.getenv("TINYHUMANS_API_KEY"), # Your Neocortex token/JWT
user_id="unique_user_id", # Unique identifier for the end user
agent_id="my_agent", # Identifier for the agent using the memory
run_id="session_123", # Optional: specific conversation session ID
params=NeocortexParams(
search_limit=10, # Max Neocortex memory chunks per query
system_prompt="Here are your past memories:",
add_as_system_message=True, # Add memories as system (True) or user (False) message
),
)- At least one of
user_id,agent_id, orrun_idmust be provided. NeocortexParams.search_limitis passed to Neocortex asmaxChunks.
This plugin now includes the same endpoint families exposed by the Mastra plugin:
POST /v1/memory/insertPOST /v1/memory/queryPOST /v1/memory/admin/deletePOST /v1/memory/syncPOST /v1/memory/recallPOST /v1/memory/memories/recallPOST /v1/memory/chatPOST /v1/memory/interactPOST /v1/memory/documentsPOST /v1/memory/documents/batchGET /v1/memory/documentsGET /v1/memory/documents/:documentIdDELETE /v1/memory/documents/:documentIdPOST /v1/memory/queriesPOST /v1/memory/conversationsPOST /v1/memory/interactionsPOST /v1/memory/memories/thoughtsGET /v1/memory/ingestion/jobs/:jobId
Place NeocortexMemoryService between your context aggregator and LLM in the Pipecat pipeline:
from pipecat.pipeline.pipeline import Pipeline
pipeline = Pipeline([
transport.input(),
stt, # Speech-to-text for audio input
user_context, # User context aggregator
memory, # Neocortex memory service enhances context here
llm, # LLM for response generation
tts, # Optional: Text-to-speech
transport.output(),
assistant_context # Assistant context aggregator
])
``]
## Advanced API Surface
`NeocortexMemoryService` now also exposes Mastra-style wrappers you can call directly:
- `sync_memory`
- `recall_memory_master`
- `recall_memories`
- `chat_memory`
- `interact_memory`
- `insert_document`
- `insert_documents_batch`
- `list_documents`
- `get_document`
- `delete_document`
- `query_memory_context`
- `chat_memory_context`
- `record_interactions`
- `recall_thoughts`
- `get_ingestion_job`
Run it with:
```bash
export TINYHUMANS_API_KEY=your_neocortex_api_key
export OPENAI_API_KEY=your_openai_key
uvicorn examples.voice_demo:app --reload --host 0.0.0.0 --port 8000Then connect to /chat from your Pipecat-compatible client UI and speak; the agent will remember and reuse past conversation details via Neocortex.