Minimal example
Use these values on a trusted local machine or server. Keep project credentials out of browser code.
python
import os
from langchain_memorae import MeMoraeMemory
# Backend environment: MEMORAE_API_KEY, MEMORAE_SUBJECT_ID,
# MEMORAE_BASE_URL=https://memora-singapore.onrender.com
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"),
)
# Submit a user fact. Processing and indexing happen asynchronously.
memory.save_context(
{"input": "I like mangoes."},
{"output": "Thanks for sharing."},
)
# Later, once the memory is active and indexed:
print(memory.load_memory_variables({"input": "What fruit do I like?"})["history"])Check that it works
- Run a search for the subject and namespace you configured.
- Submit a source message with `save_context`; processing is asynchronous.
- After processing and indexing complete, search again for a directly supported detail.
- Use `MeMoraeRetriever.invoke(query)` when your chain expects LangChain Documents. A connected MCP server does not cause LangChain to save automatically; call save_context for each turn you choose to submit.