Skip to content

a simple ai agent implementation using coinbase's cdp agentkit

Notifications You must be signed in to change notification settings

haiderameez/coinbase-ai-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Coinbase AI Agent

This repository demonstrates how to initialize and run an on-chain interaction agent using an open-source language model (Meta-Llama 3.2 1B) combined with the Coinbase Developer Platform (CDP) AgentKit. The agent leverages various toolkits and utilities to interact with on-chain tools, process user input, and provide insightful responses related to blockchain topics.

Usage Guide

1. Download the Repository using

git clone https://github.com/haiderameez/coinbase-ai-agent

2. Install all the dependencies using the following line of code:

pip install -r requirements.txt

3. Environment Variables

  • Create a .env file in the root directory and set the following environment variables with your credentials.
  • Go to https://docs.cdp.coinbase.com/cdp-apis/docs/welcome and get API keys.
  • Download the config.json file and create .env file.
  • Store these two in a .env file
CDP_API_KEY_NAME = your_cdp_api_key_name

CDP_API_KEY_PRIVATE_KEY = your_cdp_api_private_key

NETWORK_ID = your_network_id
  • Set your own network_id depending on the use case.

4. Setting up Meta-Llama 3.2 1B

5. Understanding the Code Structure

  • Model & Tokenizer Setup: The code uses Hugging Face’s transformers library to load the Meta-Llama 3.2 1B model and its tokenizer.

  • CDP AgentKit Integration: The CdpAgentkitWrapper is initialized using your API credentials to establish a connection with the CDP ecosystem. The CdpToolkit extracts a set of tools that the agent can use for on-chain interactions.

  • Agent Configuration: The agent is created using create_react_agent from the langgraph library, with a specific state_modifier message that configures its on-chain behavior. The configuration includes thread identifiers and checkpoint settings for memory persistence.

  • Agent Invocation: The agent receives an input message (e.g., explaining how ERC-721 tokens differ from ERC-20 tokens) and processes it using its integrated tools to generate a response.

6. Running the Agent

  • Run the main script using

    python main.py
  • This will return an output from the agent.

Please go to these resources to get more information

  1. https://docs.cdp.coinbase.com/agentkit
  2. https://github.com/coinbase/agentkit
  3. https://python.langchain.com/docs/integrations/tools/cdp_agentkit/
  4. https://huggingface.co/meta-llama/Llama-3.2-1B

About

a simple ai agent implementation using coinbase's cdp agentkit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages