Skip to main content

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

langchain_mengram-0.2.1.tar.gz (5.4 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.2.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mengram-0.2.1.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

Hashes for langchain_mengram-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f2ffa5b063ee1663d3772d0ca1693792333eec8fae46c91562a3c9e4e7f0ba57
MD5 77d156cdfe181363f31c08c1856365a0
BLAKE2b-256 36916eca7c216bb0a501ad9d44aee94256a8247423498b11f6c823c89dbf58a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mengram-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c5b21a397a2ff600e35a74ff202df9376d527ddb18ec9128932569c72712484
MD5 474d9b7f881f1f46ca4ae403e330afc8
BLAKE2b-256 ac1fb0fcc9b63459cc59d468572f3328e21b6279c467fda18e640da35a730da3

See more details on using hashes here.

Supported by

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