Skip to main content

LangChain adapter for Mnemo — drop-in BaseMemory and Retriever backed by the Mnemo SDK.

Project description

ledgermem-langchain

LangChain adapter for LedgerMem — drop-in conversational memory and retriever backed by the LedgerMem SDK.

Install

pip install ledgermem-langchain

Quickstart

from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
from ledgermem import LedgerMem
from langchain_ledgermem import LedgerMemMemory

mem_client = LedgerMem(api_key="lm_...", workspace_id="ws_...")
chain = ConversationChain(
    llm=ChatOpenAI(model="gpt-4o-mini"),
    memory=LedgerMemMemory(client=mem_client, top_k=5),
)

print(chain.invoke({"input": "Remember that my favourite framework is FastAPI."}))
print(chain.invoke({"input": "What is my favourite framework?"}))

Retriever for RAG

from langchain_ledgermem import LedgerMemRetriever

retriever = LedgerMemRetriever(client=mem_client, top_k=8)
docs = retriever.invoke("show me what I said about deployments")
for doc in docs:
    print(doc.metadata.get("score"), doc.page_content)

What you get

  • LedgerMemMemory — implements langchain_core.memory.BaseMemory. Auto-saves every user / AI turn and rehydrates the top-K relevant prior turns by semantic search.
  • LedgerMemRetriever — implements langchain_core.retrievers.BaseRetriever. Returns LangChain Document objects with score and memory_id in metadata.

License

MIT — see LICENSE.

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

getmnemo_langchain-0.1.0.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.

getmnemo_langchain-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: getmnemo_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for getmnemo_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38bec11fd5e810256cbcbb00e5712826cd4191dfe292a69930c1a7f99f4897b6
MD5 e9bda62dc9ced1c9979723faa83f3bea
BLAKE2b-256 2f686bda224ac9887313c8c4e9a0518cead06fa2f1036d613fbca1b63612f806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for getmnemo_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 932dd0b2a99d5173c5c5163dc7d5308ca6999c20fda405f83e1d05876a9cc710
MD5 a84639376db436ec6da1ca194c957260
BLAKE2b-256 d43aef92e67e5d31570fb65fc1f08357ac967bcdeed4876e141d5f3f43bb6cc5

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