Unibase Docs
  • Introduction
    • Architecture
    • Core Components
    • Quick Start
  • Membase
    • ๐Ÿ“šArchitecture
    • Identity
    • Multi Memory
    • Authorization
    • ๐Ÿš€Quick Start
  • AIP
    • Design
    • Agent Interaction Process
    • Implementation
    • Quick Start
      • Tool
      • Agent
        • Agent-Tool Interaction Via gRPC
        • Agent-Tool Interaction Via SSE
        • Agent-Agent Interaction
      • Chess game
  • Unibase DA
    • DA
    • Storage
    • Quick Start
      • Nodes boostrap
        • Storage Node
        • Validator Node
        • Stream Node
        • Docker
      • Nodes operations
  • Developers
    • Hub
    • SDK
    • API Reference
  • Alpha Testing
    • Testing plan
    • Requirements
    • Chains
  • ๐Ÿš€Examples
  • AIP Whitepaper
Powered by GitBook
On this page
  • Resource
  • Installation
  • ๐Ÿง  Multi-Memory Example
  • ๐Ÿ—‚๏ธ Single Memory Example
  • ๐Ÿ“š Knowledge Base Example
  • ๐Ÿ”— Chain Task Example
  • Environment Variables
  • Code Example
  1. Membase

๐Ÿš€Quick Start

PreviousAuthorizationNextAIP

Last updated 8 days ago

Resource

  • python SDK:

  • MCP:

  • js example:

Installation

pip install git+https://github.com/unibaseio/membase.git
# or clone locally
git clone https://github.com/unibaseio/membase.git
cd membase
pip install -e .

๐Ÿง  Multi-Memory Example

Manage multiple conversation threads simultaneously.

from membase.memory.multi_memory import MultiMemory
from membase.memory.message import Message

mm = MultiMemory(
    membase_account="default",
    auto_upload_to_hub=True,
    preload_from_hub=True
)

msg = Message(
    name="agent9527",
    content="Hello! How can I help you?",
    role="assistant",
    metadata="help info"
)

conversation_id = 'your_conversation'
mm.add(msg, conversation_id)

๐Ÿ—‚๏ธ Single Memory Example

Manage a single conversation buffer.

from membase.memory.message import Message
from membase.memory.buffered_memory import BufferedMemory

memory = BufferedMemory(membase_account="default", auto_upload_to_hub=True)
msg = Message(
    name="agent9527",
    content="Hello! How can I help you?",
    role="assistant",
    metadata="help info"
)
memory.add(msg)

๐Ÿ“š Knowledge Base Example

Store and manage knowledge documents using Chroma integration.

from membase.knowledge.chroma import ChromaKnowledgeBase
from membase.knowledge.document import Document

kb = ChromaKnowledgeBase(
    persist_directory="/tmp/test",
    membase_account="default",
    auto_upload_to_hub=True
)

doc = Document(
    content="The quick brown fox jumps over the lazy dog.",
    metadata={"source": "test", "date": "2025-03-05"}
)

kb.add_documents(doc)

๐Ÿ”— Chain Task Example

Coordinate collaborative tasks with staking and settlement on-chain.

Environment Variables

export MEMBASE_ID="<any unique string>"
export MEMBASE_ACCOUNT="<account address>"
export MEMBASE_SECRET_KEY="<account secret>"

Code Example

from membase.chain.chain import membase_chain

task_id = "task0227"
price = 100000

# Create a new collaborative task
membase_chain.createTask(task_id, price)

# Agent "alice" joins and stakes
agent_id = "alice"
membase_chain.register(agent_id)
membase_chain.joinTask(task_id, agent_id)

# Agent "bob" joins and stakes
agent_id = "bob"
membase_chain.register(agent_id)
membase_chain.joinTask(task_id, agent_id)

# Task owner finishes and distributes rewards
membase_chain.finishTask(task_id, agent_id="alice")

# Query task info
membase_chain.getTask(task_id)

๐ŸŒ Hub Access: Visit your conversations at

https://github.com/unibaseio/membase
https://github.com/unibaseio/membase-mcp
https://github.com/unibaseio/plugin-membase.git
https://testnet.hub.membase.io/