API Documentation for Axion Framework
The Axion Framework provides robust APIs for developers to interact with swarm nodes, integrate LLMs, manage tasks, and enable decentralized collaboration efficiently.
1. SwarmNode Class
The SwarmNode
class facilitates decentralized communication between agents using IPFS.
Methods
send_decentralized_message(message)
Send a message via IPFS.Example:
retrieve_decentralized_message(ipfs_hash)
Retrieve a message from IPFS using its hash.Example:
2. TaskScheduler Class
The TaskScheduler
class manages task allocation and distribution among agents in the swarm.
Methods
add_task(node_id, task, priority)
Add a task to the scheduler with an assigned priority.Example:
assign_task(nodes)
Dynamically assign tasks to nodes based on priority.Example:
3. SwarmConsensus Class
The SwarmConsensus
class handles collaborative decision-making within the swarm.
Methods
propose_task(task_description)
Propose a task for the swarm to vote on.Example:
vote(proposal_id)
Vote on a task proposal.Example:
get_consensus()
Check if a task proposal has reached consensus.Example:
4. IPFSClient Class
The IPFSClient
class allows agents to store and retrieve data in a decentralized manner using IPFS.
Methods
upload_file(file_path)
Upload a file to IPFS.Example:
retrieve_file(cid, output_path)
Retrieve a file from IPFS using its CID.Example:
5. Task Execution Examples
Example 1: Running a Swarm Simulation
Simulate a swarm of 10 nodes for 5 iterations:
Example 2: Decentralized Messaging
Send and retrieve messages using IPFS:
Example 3: Task Scheduling
Add tasks to the scheduler and dynamically assign them to agents:
6. Integration Notes
Environment Variables
Securely configure wallets for blockchain integration:
Modular Components
Each component (e.g., IPFSClient
, SwarmConsensus
) operates independently or as part of an integrated workflow.
Extensibility
Developers can extend the core classes to implement custom workflows or adapt the framework for specific use cases.
7. Common Errors and Troubleshooting
Error
Solution
FileNotFoundError: Wallet path
Ensure the SOLANA_WALLET_PATH
environment variable is set correctly.
ValueError: Private key missing
Set the ETHEREUM_WALLET_PRIVATE_KEY
variable in your environment.
Consensus not reached
Verify active voting agents or increase the consensus threshold as needed.
Last updated