Drop-in LangChain integration for Neruva agent memory. Wraps BaseChatMessageHistory + BaseMemory + BaseRetriever to auto-pipe agent turns into the Neruva substrate (records + KG + federated agent_context). One-line install, works with every LangChain LLM.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neruva_langchain-0.1.0.tar.gz.
File metadata
- Download URL: neruva_langchain-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18c164db8bd69f0bb0c86f885f6b1e3f034b1ffbe79e30447033c69530f7f59c
|
|
| MD5 |
3c31a1120bb7d3aea6f79d9058bb590e
|
|
| BLAKE2b-256 |
4b9f4bf0bc6669841012e1fcd1b34f5d203851b61d5f5be93aed4bb181346780
|
File details
Details for the file neruva_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: neruva_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6978aedcbced19ec20d2d19e397d8162a7836e1047be122ba3863d09790b70c6
|
|
| MD5 |
201b95e086a169c3cdd878ed80d4cf82
|
|
| BLAKE2b-256 |
d23c3d5d968c87b55d454b5f0a0f95dc6e6485d500e8259aa1beb37f8957ad13
|