Permanent memory for AI agents on the blockchain
Project description
ChainMemory Python SDK
Permanent memory for AI agents on the ChainMemory blockchain.
Install
pip install chainmemory
Quick Start
from chainmemory import ChainMemory
# Generate new API key
cm = ChainMemory.create()
# Get AIC from https://faucet.chainmemory.ai
# Or use existing key
cm = ChainMemory(api_key="aic_...")
# Register your AI
cm.register("MyAgent", "gpt-4")
# Write a memory (instant response, syncs to blockchain in ~30s)
memory = cm.remember(
"Decided to use Python for ML pipeline",
category="DECISION",
importance=8
)
print(memory["memory_id"]) # 1
print(memory["tier"]) # episodic
print(memory["chain_sync"]) # pending -> synced in 30s
# Recall memories
memories = cm.recall(limit=10)
for m in memories:
print(f"[{m['category']}] {m['summary']}")
# Get profile
profile = cm.profile()
print(f"Total memories: {profile['local_memories']}")
print(f"Synced to chain: {profile['synced_memories']}")
# Network stats (no API key needed)
stats = ChainMemory.stats()
print(f"Block: {stats['block']}")
print(f"Chain ID: {stats['chain_id']}")
LangChain Integration
from langchain.memory import ConversationBufferMemory
from chainmemory import ChainMemory
cm = ChainMemory(api_key="aic_...")
cm.register("LangChainAgent", "gpt-4")
# Save conversation turns to ChainMemory
def save_to_chainmemory(human_input, ai_output):
cm.remember(
f"User: {human_input[:140]} | AI: {ai_output[:140]}",
category="INTERACTION",
importance=5,
platform="langchain"
)
Categories
| Category | Use Case |
|---|---|
| DECISION | Important decisions made |
| LEARNING | New knowledge acquired |
| INTERACTION | Conversation summaries |
| STATE | Agent state changes |
| ERROR | Errors and corrections |
| MILESTONE | Key achievements |
| CUSTOM | Everything else |
Network
| Field | Value |
|---|---|
| Chain ID | 202604 |
| Currency | AIC (native) |
| RPC | https://rpc.chainmemory.ai |
| Explorer | https://chainmemory.ai |
| Faucet | https://faucet.chainmemory.ai |
License
MIT — ChainMemory — The permanent memory layer for artificial intelligence.
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
chainmemory-1.0.0.tar.gz
(4.4 kB
view details)
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 chainmemory-1.0.0.tar.gz.
File metadata
- Download URL: chainmemory-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b9b629d1951005ebc0ba4f742b637d0d45cf21c494f4b07549c44ff0ca4244
|
|
| MD5 |
65fe0c3991d176e9a924c173b6031c7e
|
|
| BLAKE2b-256 |
772866487fd950f1f5f0e50ecbd3da4dd4c8823ca0124146ccb20429a85dbc6f
|
File details
Details for the file chainmemory-1.0.0-py3-none-any.whl.
File metadata
- Download URL: chainmemory-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23182c96838c4d56a54499c2ad5ac7ac6641f1094f1d0796a7b4c3479ed70940
|
|
| MD5 |
f5b2d7e55c1ebe818527b3d7f9eb22ea
|
|
| BLAKE2b-256 |
159d8a55d1dd4a4c8e5ecbf79f3a3ed4630173b73eed2286b0fc2e20984017e5
|