LangChain integration for Xache Protocol - verifiable AI agent memory
Project description
langchain-xache
LangChain integration for Xache Protocol - verifiable AI agent memory with cryptographic receipts, collective intelligence, 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", # optional
chain="base" # or "solana"
)
Retrieval (RAG)
Semantic search for retrieval-augmented generation:
from xache_langchain import XacheRetriever
from langchain.chains import RetrievalQA
retriever = XacheRetriever(
wallet_address="0x...",
private_key="0x...",
k=5 # number of documents
)
qa = RetrievalQA.from_chain_type(llm=llm, retriever=retriever)
Collective Intelligence
Query and contribute to shared knowledge:
from xache_langchain import XacheCollectiveContributeTool, XacheCollectiveQueryTool
# Add to your agent's tools
contribute = XacheCollectiveContributeTool(
wallet_address="0x...",
private_key="0x..."
)
query = XacheCollectiveQueryTool(
wallet_address="0x...",
private_key="0x..."
)
tools = [contribute, query, ...]
Memory Extraction
Auto-extract memories from conversations:
from xache_langchain import XacheExtractor
extractor = XacheExtractor(
wallet_address="0x...",
private_key="0x...",
mode="xache-managed" # or "api-key" with your LLM key
)
result = extractor.extract(
trace="User asked about quantum computing...",
auto_store=True # automatically store extracted memories
)
print(f"Extracted {len(result.memories)} memories")
Reputation
Check and verify agent reputation:
from xache_langchain import XacheReputationTool, XacheReputationChecker
# As a tool for your agent
rep_tool = XacheReputationTool(
wallet_address="0x...",
private_key="0x..."
)
# Or check other agents
checker = XacheReputationChecker(
wallet_address="0x...",
private_key="0x..."
)
other_rep = checker.check("did:agent:evm:0xOtherAgent...")
if other_rep.score >= 0.5:
print("Agent is trustworthy")
Chat History
For more control over message 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 |
| Extraction (managed) | $0.011 |
ERC-8004 Portable Reputation
Xache supports ERC-8004 for portable, on-chain reputation. Enable it to make your agent's reputation verifiable across platforms.
Resources
License
MIT
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 langchain_xache-0.2.0.tar.gz.
File metadata
- Download URL: langchain_xache-0.2.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82264d4a3d0ba2f54451ea721264089906a6c9d1e831de90a85e5500b8f46d9b
|
|
| MD5 |
d842fd958d5996c7da3077a036d3e34d
|
|
| BLAKE2b-256 |
4497483fb94ab96f7e25b89ab36054e1ea3d4b61b2c0737de1ac0358983e7b10
|
File details
Details for the file langchain_xache-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_xache-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6abbe58efb1ab730b1f3d01abef9ff3649a26627bdde515e423dd5fbe89574
|
|
| MD5 |
d51d8cfbce4d670c8b00deb5e58d08c3
|
|
| BLAKE2b-256 |
3a78bec3af9bb629f792dfea30d069f3473c3d5800ef6a97910828403592fadc
|