LangChain integration for Mengram — AI memory with semantic, episodic, and procedural memory types.
Project description
langchain-mengram
LangChain integration for Mengram — AI memory with semantic, episodic, and procedural memory types.
Installation
pip install langchain-mengram
Quick start
from langchain_mengram import MengramRetriever
retriever = MengramRetriever(
api_key="om-...",
user_id="user-123",
)
docs = retriever.invoke("deployment issues")
for doc in docs:
print(doc.metadata["memory_type"], doc.page_content)
What it does
MengramRetriever searches across all three Mengram memory types and returns LangChain Document objects:
- Semantic — facts, entities, and knowledge graph relationships
- Episodic — events, experiences, and their outcomes
- Procedural — workflows, step-by-step procedures, and learned routines
Each document includes metadata["memory_type"] so you can filter or prioritize by type.
Use in a chain
from langchain_mengram import MengramRetriever
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
retriever = MengramRetriever(api_key="om-...", user_id="user-123")
llm = ChatOpenAI(model="gpt-4o-mini")
prompt = ChatPromptTemplate.from_messages([
("system", "Use the following memory context to answer:\n\n{context}"),
("human", "{question}"),
])
chain = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
chain.invoke("What deployment steps did we follow last time?")
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | required | Mengram API key (starts with om-) |
user_id |
str | "default" |
User to search memories for |
api_url |
str | "https://mengram.io" |
Mengram API base URL |
top_k |
int | 5 |
Max results per memory type |
memory_types |
list | ["semantic", "episodic", "procedural"] |
Which types to search |
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_mengram-0.2.0.tar.gz.
File metadata
- Download URL: langchain_mengram-0.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d850392ebf3ea86f397b09529b50df44425a7a33da9aaf6ee0d9034c19275a5
|
|
| MD5 |
68f28dec58ad118d4e63879ec70a4251
|
|
| BLAKE2b-256 |
f77d3b411436ed8f880f09063d101f0de43c2b77c849614becb37d99de4132a4
|
File details
Details for the file langchain_mengram-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mengram-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e4bed2a2ca6c45bb03e213045e6cf74d2323096a502695f78522e9aa5e2f3be
|
|
| MD5 |
c013365abc56ceb89d5424d030f968c0
|
|
| BLAKE2b-256 |
e11e7fe75f157ff10a407ea6bfc2c3721f5a1deed3db94dbcda2daeaf6e0cedb
|