CommuneAI Developer Documentation

website·Indexed 30 days ago

https://main--beautiful-dasik-25264d.netlify.app

Developer documentation for CommuneAI, featuring guides on the Commune CLI, module basics, and the module filesystem. Includes tutorials for deploying miners and validators, as well as technical details on the Subspace module and subnets.

Tokens
4K
Snippets
36
Records
44
Agent score
75%

What's inside CommuneAI

  1. Overview of the CommuneAI Protocol

    Commune is an unopinionated protocol designed to connect developer tools into a single network to create a shareable, reusable, and open economy. Its design philosophy allows developers to integrate Commune as a versatile set of tools alongside existing projects without imposing rigid structures or constraints, enabling a collaborative ecosystem for sharing and extending tools.
  2. Inspect server and module information

    Use the servers command to list active servers and the info call to retrieve detailed metadata about a specific module, including its address, available functions, attributes, hardware specs, and schema.
    # List all servers
    c servers
    
    # Get detailed info for a specific module
    c call model.openai/info
    # List servers via programmatic interface
    c.servers()
  3. Understand the role of Subspace in Commune

    Subspace is the blockchain utilized by Commune for two primary functions:

    1. DNS for Python: Provides a Decentralized Name Service for deployed objects.
    2. Performance Evaluation: Implements a stake-weighted voting system allowing users to evaluate each other's performance, replacing the need for self-reported network data.
  4. Organize modules using the Commune module filesystem

    Commune uses a module filesystem where the module.py file acts as an anchor. Modules are organized by directory paths; for example, a dataset module stored in {PWD}/dataset/text is assigned the path dataset.text. Currently, the configuration requires the name of the config to match the Python object name.
  5. Stake tokens to a Subspace Module

    Stake tokens to a specific module using its address or stake to multiple modules simultaneously using the stake_many command. For stake_many, you can provide a list of amounts or a single integer to apply the same amount to all specified modules.
    # Stake to a single module by address
    c stake 5HYnok8FmBEx9AekVUPzff9kW7ymyp9mrucQTeqTLfJoHu1S 100
    
    # Stake to multiple modules with different amounts
    c stake_many modules=[model1,model2] amounts=[10,20]
    
    # Stake to multiple modules with the same amount
    c stake_many modules=[model1,model2] amounts=10
  6. Register a miner/validator on the network

    To register a validator with a specific tag, you can use the CLI or a Python script. By default, these commands target netuid 0 and the commune subnet.
    # CLI registration
    c register vali::whadup
    
    # Alternative CLI registration with explicit parameters
    c model.openai register tag=whadup subnet=commune
    # Python registration
    c.module('model.openai').register(tag='whadup', subnet=commune)
  7. Call a miner function

    You can interact with a registered miner by calling its functions (e.g., forward) using the CLI, a direct call method, or by establishing a connection to the model.
    # CLI call
    c model.openai::whadup forward sup
    # Direct call
    c.call("model.openai::whadup/forward", "sup")
    
    # Connection-based call
    model = c.connect('model.openai')
    model.forward('sup')
  8. Register a miner/validator on the network

    To register a validator with a specific tag and assign it to a subnet, use the register command. You can perform this action via the CLI or the programmatic interface.
    # CLI approach
    c register model.openai register tag=whadup subnet=commune
    # Programmatic approach
    c.module('model.openai').register(tag='whadup', subnet=commune)
  9. Update a Subspace Module's configuration

    You can update a module's name and address. Note: If you update the module's name, you must restart the server with the new name for changes to take effect.
    c update_module model.openai name=model.openai::fam1 address=124.545.545:8080
  10. Update subnet parameters via Democratic Voting

    When vote_mode is set to stake, changes are made via a proposal system. A proposal must reach a 50% stake threshold to be accepted.
    # Propose a change
    c propose_update_subnet name=wadup tempo=10
    
    # Vote for a proposal
    c vote_proposal id=10 key=myvotingkey
    
    # Remove a vote from a proposal
    c unvote_proposal id=10
  11. Unstake tokens from a Subspace Module

    Unstake tokens from a module using either the module's address or its name.
    # Unstake by address
    c unstake 5HYnok8FmBEx9AekVUPzff9kW7ymyp9mrucQTeqTLfJoHu1S 10
    
    # Unstake by module name
    c unstake module=model.openai amount=100