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.1.0.tar.gz (4.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.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mengram-0.1.0.tar.gz
  • Upload date:
  • Size: 4.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.1.0.tar.gz
Algorithm Hash digest
SHA256 4d50bd0f08ba92a8d42487f3b8bf68df7a17e1afe75c611e9950ac5eb06ae04f
MD5 f73dd7bd0ee5f2a6b6fffb0edd0cc0c1
BLAKE2b-256 96186703626ac8ee1f4907974bdbad74e1d51f40a4872244eb51631d8694a42d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mengram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8767a22388ea3a947bb26e7c8ffd95f0fa2f0c15199f295b68d808f956d3c8d8
MD5 268270d53084fd5bb5ba613a1502a4c7
BLAKE2b-256 756b22f7f347af5eeab912ee132c39d6d6a180f0cfcbfeedfac6d1aa25b51b62

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