langchain-memorae
MeMorae memory and retrieval adapters for LangChain, LangGraph, and local chatbots.
What it does
langchain-memorae connects Python applications to an existing MeMorae backend with a project API key. It can save user and optionally assistant messages as sources, then retrieve relevant long-term memory context for a conversation. MeMorae controls extraction, approval, and retrieval; the package does not bypass those rules.
Install
python -m pip install langchain-memorae
For the hosted service, your backend connects to https://memora-singapore.onrender.com; you do not need a local MeMorae server. Self-hosted deployments use their own API origin. LangChain core and the classic memory interface are installed as package dependencies. The examples have optional dependencies: python -m pip install 'langchain-memorae[examples]'.
Development install
From the repository root, install an editable copy:
python -m pip install -e integrations/langchain-memorae
Configure
Set these variables in the server environment where your chatbot runs:
| Variable | Purpose |
|---|---|
MEMORAE_API_KEY |
MeMorae project API key |
MEMORAE_BASE_URL |
Hosted API URL: https://memora-singapore.onrender.com (self-hosted users substitute their own API origin) |
MEMORAE_SUBJECT_ID |
Stable identifier for the end user |
MEMORAE_NAMESPACE |
Optional memory space; defaults to default |
Create a project API key in Dashboard → API Keys. Select the same project under Projects → Connection details and copy its personal Subject ID, or derive a stable Subject ID for each authenticated user in a multi-user app. Store the key in a server-side secret manager or an untracked .env file. A .env file is not loaded automatically by this package; load it in your application or export the variables before running Python.
Quickstart
import os
from langchain_memorae import MeMoraeMemory
memory = MeMoraeMemory(
api_key=os.environ["MEMORAE_API_KEY"],
base_url=os.environ["MEMORAE_BASE_URL"],
subject_id=os.environ["MEMORAE_SUBJECT_ID"],
namespace=os.getenv("MEMORAE_NAMESPACE", "default"),
)
memory.save_context({"input": "I love pizza."}, {"output": "Got it."})
# This source is processed asynchronously. Search again once it is active and indexed.
print(memory.load_memory_variables({"input": "What food do I like?"})["history"])
history is a compact string containing the memories returned for the input query. Messages are submitted for asynchronous MeMorae processing. An immediate search can be empty; supported facts become retrievable after extraction and indexing complete.
LangChain memory
Call load_memory_variables before generating the response, then save_context with the turn. Set save_assistant=True if assistant messages should also be submitted as sources; by default, only the user message is saved.
from langchain_memorae import MeMoraeMemory
memory = MeMoraeMemory(
api_key=api_key,
base_url=base_url,
subject_id=subject_id,
namespace=namespace,
save_assistant=True,
)
context = memory.load_memory_variables({"input": question})["history"]
answer = chatbot.generate(question, context=context)
memory.save_context({"input": question}, {"output": answer})
Retriever
Use MeMoraeRetriever anywhere a LangChain retriever is accepted. invoke returns LangChain Document objects; each document includes memory_id, type, and available source_ids metadata.
from langchain_memorae import MeMoraeRetriever
retriever = MeMoraeRetriever(
api_key=api_key,
base_url=base_url,
subject_id=subject_id,
namespace=namespace,
)
docs = retriever.invoke("What sports do I enjoy?")
LangGraph
Use a recall node before the answer node. Pass the recalled context into the prompt, then use a save node after the answer to record the user turn. The complete runnable example is in examples/langgraph_chatbot.py.
def recall(state):
return {"history": memory.load_memory_variables({"input": state["input"]})["history"]}
def save(state):
memory.save_context({"input": state["input"]}, {"output": state["output"]})
return {}
Local chatbot integration
For Flask, Ollama, or another local Python chatbot, load memories for the incoming message, add the returned string to your prompt or context, generate the answer, and save the user message and (optionally) assistant answer. See examples/local_chatbot_flask.py. The ChatOpenAI example is in examples/basic_chatbot.py.
Indexing and troubleshooting
Ingestion is asynchronous. Newly submitted messages can take time to appear in retrieval. For the hosted service, check the selected project and API status. Self-hosted operators should also verify their worker, Beat, and retrieval indexes.
| Symptom | What to check |
|---|---|
history is empty |
Wait for processing and indexing. For local Docker, check worker, Beat, OpenSearch, and Qdrant. |
HTTP 503 |
MeMorae search or an indexing service may be unavailable. Check backend and index service health. |
HTTP 401 or 403 |
Confirm the project API key is valid, active, and belongs to the intended project. |
pip cannot install globally on macOS |
Create and activate a Python virtual environment, then install inside it. |
Security and scope
Keep MEMORAE_API_KEY on the server. Never expose it in browser JavaScript, commit .env, or print the key in logs. Use one stable subject_id per end user so their memories remain scoped to that user. Use namespace to separate memory spaces for the same subject, and pass the same subject and namespace when saving and retrieving.
clear() does not delete remote MeMorae memories. Manage remote memory lifecycle through the MeMorae dashboard and its review controls.
Metadata
Release files for langchain-memorae 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_memorae-0.1.2.tar.gz | 7.4 kB | Without provenance | Details for langchain_memorae-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_memorae-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for langchain_memorae-0.1.2-py3-none-any.whl |
Total release size: 14.9 kB
Release files / langchain_memorae-0.1.2.tar.gz
| Download URL | langchain_memorae-0.1.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c130c60b4cff091f342f8cf0a9a4cb2da9248502837ecfdc0fc4a33ce8dd9a2
|
|
BLAKE2b-256 checksum How to use checksums |
2278b59b770ee925b7c377fd3b88e8cf1580cdb0ac64b28370c9111611d7d5d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / langchain_memorae-0.1.2-py3-none-any.whl
| Download URL | langchain_memorae-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f647771ef67273159ada896876d7e7268196ae433e0721807c9c4123cb7fe117
|
|
BLAKE2b-256 checksum How to use checksums |
2bc6d3ddff8da62b5407447f5d02cab21f4106ae0fd0c4af46461f7418cab3ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for langchain-memorae 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.