Skip to main content

AutoGen integration for Xache Protocol - verifiable AI agent memory

Project description

autogen-xache

AutoGen 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 autogen-xache

Quick Start

Create an Agent with Xache Memory

from autogen import UserProxyAgent
from xache_autogen import XacheAssistantAgent

assistant = XacheAssistantAgent(
    name="assistant",
    wallet_address="0x...",
    private_key="0x...",
    llm_config={"model": "gpt-4"}
)

user_proxy = UserProxyAgent(
    name="user",
    human_input_mode="TERMINATE"
)

user_proxy.initiate_chat(
    assistant,
    message="Research quantum computing and remember the key findings"
)

Add Xache Functions to Any Agent

from autogen import AssistantAgent
from xache_autogen import xache_functions

llm_config = {
    "model": "gpt-4",
    "functions": xache_functions
}

agent = AssistantAgent(name="researcher", llm_config=llm_config)

Available Functions

Memory Functions

  • xache_memory_store - Store information with cryptographic receipts
  • xache_memory_retrieve - Retrieve stored memories by semantic search

Collective Intelligence Functions

  • xache_collective_contribute - Share insights with other agents
  • xache_collective_query - Learn from community knowledge

Knowledge Graph Functions

  • xache_graph_extract - Extract entities/relationships from text
  • xache_graph_load - Load the full knowledge graph
  • xache_graph_query - Query graph around an entity
  • xache_graph_ask - Ask natural language questions about the graph
  • xache_graph_add_entity - Add an entity manually
  • xache_graph_add_relationship - Create a relationship between entities
  • xache_graph_merge_entities - Merge duplicate entities
  • xache_graph_entity_history - View entity version history

Ephemeral Context Functions

  • xache_ephemeral_create_session - Create a short-lived working memory session
  • xache_ephemeral_write_slot - Write data to a session slot (conversation, facts, tasks, cache, scratch, handoff)
  • xache_ephemeral_read_slot - Read data from a session slot
  • xache_ephemeral_promote - Promote session to persistent memory
  • xache_ephemeral_status - Get session status and details

Extraction Functions

  • xache_extract_memories - Extract memories from conversation text using LLM

Reputation Functions

  • xache_check_reputation - View reputation score and ERC-8004 status

Ephemeral Context

Ephemeral context gives agents short-lived scratch sessions for multi-turn workflows. Sessions have 6 named slots and auto-expire.

from xache_autogen import (
    ephemeral_create_session,
    ephemeral_write_slot,
    ephemeral_read_slot,
    ephemeral_promote,
    ephemeral_status,
)

config = {
    "wallet_address": "0x...",
    "private_key": "0x...",
}

# Create a session (1 hour TTL)
session = ephemeral_create_session(ttl_seconds=3600, **config)
session_key = session["sessionKey"]

# Write context to slots
ephemeral_write_slot(
    session_key=session_key,
    slot="facts",
    data={"user_name": "Alice", "topic": "quantum computing"},
    **config
)

ephemeral_write_slot(
    session_key=session_key,
    slot="tasks",
    data={"pending": ["summarize findings", "generate report"]},
    **config
)

# Read slot data
facts = ephemeral_read_slot(session_key=session_key, slot="facts", **config)

# Check session status
info = ephemeral_status(session_key=session_key, **config)
print(f"Status: {info['status']}, Active slots: {info['activeSlots']}")

# Promote to persistent memory when done
result = ephemeral_promote(session_key=session_key, **config)
print(f"Created {result['memoriesCreated']} persistent memories")

Agent Types

XacheAssistantAgent

from xache_autogen import XacheAssistantAgent

assistant = XacheAssistantAgent(
    name="assistant",
    wallet_address="0x...",
    private_key="0x...",
    system_message="You are a helpful assistant with persistent memory.",
    llm_config={"model": "gpt-4"}
)

XacheMemoryAgent

from xache_autogen import XacheMemoryAgent

agent = XacheMemoryAgent(
    name="researcher",
    wallet_address="0x...",
    private_key="0x...",
    llm_config={"model": "gpt-4"}
)

Conversation Memory

from xache_autogen import XacheConversationMemory

memory = XacheConversationMemory(
    wallet_address="0x...",
    private_key="0x...",
    conversation_id="unique-session-id"
)

memory.add_message("user", "Hello!")
memory.add_message("assistant", "Hi there!")

history = memory.get_history()
results = memory.search("quantum computing")
context = memory.format_for_prompt(max_messages=5)

Multi-Agent Conversations

from autogen import UserProxyAgent, GroupChat, GroupChatManager
from xache_autogen import XacheAssistantAgent

config = {"wallet_address": "0x...", "private_key": "0x..."}

researcher = XacheAssistantAgent(
    name="researcher",
    system_message="You research topics and store findings.",
    llm_config={"model": "gpt-4"},
    **config
)

writer = XacheAssistantAgent(
    name="writer",
    system_message="You write articles based on research.",
    llm_config={"model": "gpt-4"},
    **config
)

user_proxy = UserProxyAgent(name="user")

groupchat = GroupChat(agents=[user_proxy, researcher, writer], messages=[], max_round=10)
manager = GroupChatManager(groupchat=groupchat, llm_config={"model": "gpt-4"})

user_proxy.initiate_chat(manager, message="Research AI safety and write an article")

Direct Function Usage

from xache_autogen import (
    memory_store,
    memory_retrieve,
    collective_contribute,
    collective_query,
    check_reputation,
    graph_extract,
    graph_ask,
    extract_memories,
)

config = {"wallet_address": "0x...", "private_key": "0x..."}

result = memory_store(content="Important finding", context="research", **config)
memories = memory_retrieve(query="quantum computing", limit=5, **config)
rep = check_reputation(**config)

Pricing

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

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

autogen_xache-0.4.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

autogen_xache-0.4.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file autogen_xache-0.4.0.tar.gz.

File metadata

  • Download URL: autogen_xache-0.4.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for autogen_xache-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6e5be533758f5ee390bc631efa2974f120ec400b6931089c30323e0c5141fda6
MD5 4907a47cbaf568f49f152148a6908361
BLAKE2b-256 a108f7d06f9bd23696478f55f39ac9484e4a69ac153b7fd8da998fcc80854b82

See more details on using hashes here.

File details

Details for the file autogen_xache-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: autogen_xache-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for autogen_xache-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d07583f53dd93b9aa53c5ac5b0c7042437a32ffde0ae3dee873715c5c6c1c2f
MD5 b203a916cb561e5450fc310fdbbdb36b
BLAKE2b-256 61628d5d1dab828a8ca64f0c3a4466a295db9ba80fb7a64f9f03133457b063bf

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