Skip to main content

Drop-in LangChain integration for Neruva agent memory. NeruvaChatMessageHistory (BaseChatMessageHistory) auto-pipes turns into Records + KG via agent_remember. NeruvaContextRetriever (BaseRetriever) federates Records + KG across one or many namespaces. Works with RunnableWithMessageHistory + RetrievalQA. Persists across restarts. Sub-100ms p95.

Project description

neruva-langchain

Drop-in LangChain integration for Neruva agent memory. Three wrappers cover the common LangChain plug points: chat history, conversation memory, and document retriever.

pip install neruva-langchain

NeruvaChatMessageHistory

Auto-records every turn into the Neruva Records substrate. Drop into any LangChain primitive that accepts a BaseChatMessageHistory:

from neruva_langchain import NeruvaChatMessageHistory

history = NeruvaChatMessageHistory(
    api_key="nv_...",          # or env NERUVA_API_KEY
    namespace="user_alice",    # one per user / session
)

history.add_user_message("My name is Alice and I live in Toronto.")
history.add_ai_message("Nice to meet you, Alice!")

# Later — even after process restart, substrate-backed:
print(history.messages)

Use with RunnableWithMessageHistory (modern pattern)

from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables.history import RunnableWithMessageHistory
from neruva_langchain import NeruvaChatMessageHistory

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    MessagesPlaceholder(variable_name="history"),
    ("human", "{input}"),
])
chain = prompt | ChatAnthropic(model="claude-opus-4-7")

chain_with_history = RunnableWithMessageHistory(
    chain,
    lambda session_id: NeruvaChatMessageHistory(namespace=session_id),
    input_messages_key="input",
    history_messages_key="history",
)
chain_with_history.invoke(
    {"input": "What did I tell you about my project last week?"},
    config={"configurable": {"session_id": "user_alice"}},
)

NeruvaContextRetriever

BaseRetriever for RetrievalQA chains. Returns Document objects sourced from federated agent_recall:

from neruva_langchain import NeruvaContextRetriever
from langchain.chains import RetrievalQA
from langchain_anthropic import ChatAnthropic

retriever = NeruvaContextRetriever(
    api_key="nv_...",
    namespaces=["session_a", "session_b"],   # multi-session fan-out
)
qa = RetrievalQA.from_chain_type(
    llm=ChatAnthropic(model="claude-opus-4-7"),
    retriever=retriever,
)
qa.invoke("Where does Alice work?")

Why use Neruva instead of LangChain's built-in memory?

Feature LangChain default Neruva
Persists across process restart Manual setup Built-in (GCS-backed)
Cross-session recall No Yes via namespaces=[...]
Fact extraction (KG) No Auto (hd_kg_extraction_prompt + caller LLM)
GDPR forget by user Manual user_id= auto-folds, one-call forget
Determinism / replayability No Bit-identical from seed
Portability Pickle .neruva zip container

Get an API key · Docs · Status

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

neruva_langchain-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

neruva_langchain-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file neruva_langchain-0.1.1.tar.gz.

File metadata

  • Download URL: neruva_langchain-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for neruva_langchain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3cc582245f5f3d994b06a4dd029c03195c8e242c482362b035266ea7936d869c
MD5 d3d2a97191c98c0ca4b934323477a220
BLAKE2b-256 2e067fc8a51fab7f2e87041c25837faba96c2fb765a540a2a0be48eb59532e03

See more details on using hashes here.

File details

Details for the file neruva_langchain-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for neruva_langchain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55d0d258d977e514a2367d20a447b902a2e5cb6f4a8ecdd1f3957fa7924de317
MD5 dd7403b05292c36e7a292fab2b8602d1
BLAKE2b-256 eacce29b832e0dfbcf2a8a81674e27f5526829dc1623720e054404ad8d435cd6

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