This serves as a practical example of how to integrate Agentipy toolkit with the crewAI multi-agent framework. The integration showcases:
Bringing Blockchain to AI Agents: How to equip AI agents with blockchain capabilities through Agentipy
Tool Integration: How to wrap agentipy functionality as crewAI tools
Configuration-Driven Design: Using YAML files to configure blockchain agents
Integration Pattern
The integration follows this pattern:
# 1. Import both librariesfrom crewai import Agent, Crew, Taskfrom agentipy.agent import SolanaAgentKit# 2. Create a Solana kit instancesolana_kit =SolanaAgentKit(private_key=os.getenv("SOLANA_PRIVATE_KEY"),rpc_url="https://api.devnet.solana.com")# 3. Create tools from agentipy capabilities@tool("get_sol_balance")defget_sol_balance()->str:# Use agentipy BalanceFetcher to get blockchain data balance = loop.run_until_complete(BalanceFetcher.get_balance(agent))returnf"The current SOL balance is {balance:.4f} SOL"# 4. Attach tools to crewAI agentssolana_agent =Agent(config=agents_config["solana_operator"],tools=[make_balance_tool(agent=solana_kit)],llm=ChatOpenAI(model=os.getenv("MODEL"),temperature=0))# 5. Create tasks using these agentssolana_task =Task(description="Analyze instruction and take action: {user_input}",agent=solana_agent)# 6. Orchestrate with crewAIcrew =Crew(agents=[solana_agent],tasks=[solana_task],process=Process.sequential)
This pattern demonstrates how to leverage both frameworks' strengths: