langchain-xache
LangChain integration for Xache Protocol - verifiable AI agent memory with cryptographic receipts, collective intelligence, ephemeral working memory, knowledge graph, and portable ERC-8004 reputation.
Installation
pip install langchain-xache
Quick Start
One-Line Memory Replacement
# Before (standard LangChain)
from langchain.memory import ConversationBufferMemory
memory = ConversationBufferMemory()
# After (with Xache - one line change!)
from xache_langchain import XacheMemory
memory = XacheMemory(
wallet_address="0x...",
private_key="0x..."
)
# Everything else stays the same
agent = initialize_agent(tools, llm, memory=memory)
Features
Memory Storage
Persistent memory that survives across sessions with cryptographic receipts:
from xache_langchain import XacheMemory
memory = XacheMemory(
wallet_address="0xYourWallet",
private_key="0xYourPrivateKey",
api_url="https://api.xache.xyz",
chain="base"
)
Retrieval (RAG)
from xache_langchain import XacheRetriever
from langchain.chains import RetrievalQA
retriever = XacheRetriever(
wallet_address="0x...",
private_key="0x...",
k=5
)
qa = RetrievalQA.from_chain_type(llm=llm, retriever=retriever)
Collective Intelligence
from xache_langchain import XacheCollectiveContributeTool, XacheCollectiveQueryTool
contribute = XacheCollectiveContributeTool(
wallet_address="0x...",
private_key="0x..."
)
query = XacheCollectiveQueryTool(
wallet_address="0x...",
private_key="0x..."
)
tools = [contribute, query]
Memory Extraction
from xache_langchain import XacheExtractor
extractor = XacheExtractor(
wallet_address="0x...",
private_key="0x...",
mode="xache-managed"
)
result = extractor.extract(
trace="User asked about quantum computing...",
auto_store=True
)
Knowledge Graph
Build and query a privacy-preserving knowledge graph:
from xache_langchain import (
XacheGraphExtractTool,
XacheGraphLoadTool,
XacheGraphQueryTool,
XacheGraphAskTool,
XacheGraphAddEntityTool,
XacheGraphAddRelationshipTool,
XacheGraphMergeEntitiesTool,
XacheGraphEntityHistoryTool,
XacheGraphRetriever,
)
config = {
"wallet_address": "0x...",
"private_key": "0x...",
"llm_provider": "anthropic",
"llm_api_key": "sk-ant-...",
}
extract_tool = XacheGraphExtractTool(**config)
query_tool = XacheGraphQueryTool(wallet_address="0x...", private_key="0x...")
ask_tool = XacheGraphAskTool(**config)
# Use as a retriever for RAG
graph_retriever = XacheGraphRetriever(
wallet_address="0x...",
private_key="0x...",
k=10
)
Ephemeral Context (Working Memory)
Short-lived scratch sessions for multi-turn workflows with 6 named slots (conversation, facts, tasks, cache, scratch, handoff):
from xache_langchain import (
XacheEphemeralCreateSessionTool,
XacheEphemeralWriteSlotTool,
XacheEphemeralReadSlotTool,
XacheEphemeralPromoteTool,
XacheEphemeralStatusTool,
)
# Create tools for your agent
create_session = XacheEphemeralCreateSessionTool(
wallet_address="0x...",
private_key="0x..."
)
write_slot = XacheEphemeralWriteSlotTool(
wallet_address="0x...",
private_key="0x..."
)
read_slot = XacheEphemeralReadSlotTool(
wallet_address="0x...",
private_key="0x..."
)
promote = XacheEphemeralPromoteTool(
wallet_address="0x...",
private_key="0x..."
)
status = XacheEphemeralStatusTool(
wallet_address="0x...",
private_key="0x..."
)
tools = [create_session, write_slot, read_slot, promote, status]
Typical agent workflow:
- Agent creates a session at the start of a conversation
- Writes facts, tasks, and context to slots as conversation progresses
- Reads slots to maintain context across turns
- Promotes the session to persistent memory when the conversation has lasting value
- Or lets the session expire if the context is transient
Reputation
from xache_langchain import XacheReputationTool, XacheReputationChecker
rep_tool = XacheReputationTool(
wallet_address="0x...",
private_key="0x..."
)
checker = XacheReputationChecker(
wallet_address="0x...",
private_key="0x..."
)
Chat History
from xache_langchain import XacheChatMessageHistory
from langchain.memory import ConversationBufferMemory
history = XacheChatMessageHistory(
wallet_address="0x...",
private_key="0x...",
session_id="unique-session-id"
)
memory = ConversationBufferMemory(chat_memory=history)
Pricing
All operations use x402 micropayments (auto-handled):
| Operation | Price |
|---|---|
| Memory Store | $0.002 |
| Memory Retrieve | $0.003 |
| Collective Contribute | $0.002 |
| Collective Query | $0.011 |
| Ephemeral Session | $0.005 |
| Ephemeral Promote | $0.05 |
| Extraction (managed) | $0.011 |
| Graph Operations | $0.002 |
| Graph Ask (managed) | $0.011 |
Resources
License
MIT
Metadata
Release files for langchain-xache 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_xache-0.7.0.tar.gz | 20.5 kB | Without provenance | Details for langchain_xache-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_xache-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_xache-0.7.0-py3-none-any.whl |
Total release size: 47.3 kB
Release files / langchain_xache-0.7.0.tar.gz
| Download URL | langchain_xache-0.7.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7503f22ee1a1d3cb0b95049e2c2df62417819f92e2e8a207ece19808013026c2
|
|
BLAKE2b-256 checksum How to use checksums |
7f2dae715d949889b5b25b08d3c2f168d50c7d7694511ce3bd194760acf84b88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.6
|
Release files / langchain_xache-0.7.0-py3-none-any.whl
| Download URL | langchain_xache-0.7.0-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bccf1fdd0c85c76478a29c5438ce04ef8023ec6d52f3fca32523f924bfbfb30d
|
|
BLAKE2b-256 checksum How to use checksums |
3eb2016f4e2ab9889c7a39e602494cee8aa12dd4aa7077635be371ba616f0a6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.6
|
Security for langchain-xache 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.