Skip to content

0xbohu/chain-swarm

Repository files navigation

CHAIN-SWARM ⛓️-🐛

TypeScript License: MIT

Overview

CHAIM-SWARM is a repository for implementing OpenAI Swarm API framework. The purpose of project is leverage BrianAPI and StarknetJS to experiment multi-agents collaboration and build a seamless experience with the support of multiple web2 and web3 AI agents.

Features

  • Minimal Interface: createAgentin specific code structure and add to swarm list.
  • Multi-Agent System: Create and manage multiple AI agents with different roles and capabilities, with a focus on web3 knowledge base, code generation, construct transaction callData, execute tx onchain (Starknet), and connection to web2 application(twitter)
  • Flexible Agent Configuration: Easily define agent behaviors, instructions, and available functions.
  • Task Delegation: Agents can transfer tasks to other specialized agents.
  • Tools: Agents can use tools to perform tasks.
  • Zod Validation: Tools can use zod validation to ensure the input is correct.
  • Model Choice: Currently use gpt-4o-2024-08-06 model and it is easy to switch between different LLMs by changing a single line of code.

Examples

All Agents has registered a list of available agents for this demo

  • Triage Agent: a traffic controller agent to reroute user query to other agents, also try to answer user questions using OpenAI general knowledge bases
  • Brian Agent: an agent leverage Brian API to answer user questions regarding blockchain /knowledge endpoint, providing contract code example via /smart-contract endpoint, or construct chain based tx callData via /transaction endpoint,
  • Starknet Agent: an agent to execute raw callData for starknet transactions
  • X Agent: an agent to post tweets on x.com

The result from the interaction with one agent, can be handed over to another agent to execute further instructions

Installation

Use your preferred package manager:

pnpm add

Update .env.example file to .env file with your own API credentials. Be careful here! Add .env to your .gitignore file and do not commit to public repo

Run the example:

npx tsx examples/all

Demo

Ask BrianAgent about blockahin knowledge

Ask What is uniswap get transferred to brianAgent to handle user input

Ask Brian

Post on twitter

Summarise brian's answer about Uniswap and post on twitter User: summarise brian's answer to 20 words and post on twitter Post on Twitter

Result Tweet Tweet

Get Code Example from BrianAgent

Ask brian to provide ERC20 token example User: give me an example of ERC20 token ERC20

Get Swap CallData from BrianAgent

Ask brian to prepare swap data User: swap 0.001 ETH to STRK on starknet Swap Data

Execute swap with StarknetAgent

Ask Starknet to use brian's swap calldata to execute the swap on Starknet mainnet User: execute calldata Execute swap

Result showing in AgentX wallet

AgentX

Check transation

Acknowledgements

License

This project is licensed under the MIT License - see the LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published