Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mengram-0.3.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_mengram-0.3.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mengram-0.3.0.tar.gz.

File metadata

  • Download URL: langchain_mengram-0.3.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for langchain_mengram-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c640e0034dfe38463d8adcdc53f72fa319d1f4e2b7fc215e97df00d49828ed13
MD5 ad7f40227bf9aeadf90ccec84c0455ff
BLAKE2b-256 9b0f09c895f9192bad97b38a867e1a52b420c372d02f14c0eb1d4a545953d120

See more details on using hashes here.

File details

Details for the file langchain_mengram-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mengram-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91a55af3a9f48e2736e4793b9b8678c0366b8e0c3bcb78950582634532de7472
MD5 0594803647dac85064f9277ca9eeeeb0
BLAKE2b-256 457f151f85ac08e7b0062a156596f3f894a58a32259caafdcb96969d04c0f28a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page