Coinbase Agentkit Alith Python Integration
This integration provides the following methods:
- Use Agentkit actions within Alith: You can directly leverage a variety of actions from the agentkit ecosystem without the need to rewrite them in Alith.
import json
import os
from coinbase_agentkit import (
AgentKit,
AgentKitConfig,
CdpWalletProvider,
CdpWalletProviderConfig,
cdp_api_action_provider,
cdp_wallet_action_provider,
erc20_action_provider,
pyth_action_provider,
wallet_action_provider,
weth_action_provider,
)
from coinbase_agentkit_alith import get_alith_tools
from alith import Agent
from dotenv import load_dotenv
# Configure a file to persist the agent's CDP API Wallet Data.
wallet_data_file = "wallet_data.txt"
load_dotenv()
def initialize_agent() -> Agent:
"""Initialize the agent with CDP Agentkit."""
# Initialize CDP Wallet Provider
wallet_data = None
if os.path.exists(wallet_data_file):
with open(wallet_data_file) as f:
wallet_data = f.read()
cdp_config = None
if wallet_data is not None:
cdp_config = CdpWalletProviderConfig(wallet_data=wallet_data)
wallet_provider = CdpWalletProvider(cdp_config)
agentkit = AgentKit(
AgentKitConfig(
wallet_provider=wallet_provider,
action_providers=[
cdp_api_action_provider(),
cdp_wallet_action_provider(),
erc20_action_provider(),
pyth_action_provider(),
wallet_action_provider(),
weth_action_provider(),
],
)
)
wallet_data_json = json.dumps(wallet_provider.export_wallet().to_dict())
with open(wallet_data_file, "w") as f:
f.write(wallet_data_json)
# use get_langchain_tools
tools = get_alith_tools(agentkit)
preamble = (
"Be creative and do something interesting on the blockchain. "
"Choose an action or set of actions and execute it that highlights your abilities."
)
# Create an Alith Agent and CDP Agentkit tools.
return Agent(
name="A dummy Agent",
model="gpt-4o-mini",
preamble=preamble,
tools=tools,
)
agent = initialize_agent()
print(agent.prompt("Transfer 0.5 ETH to 0xAABB"))
Reference
Metadata
Release files for coinbase-agentkit-alith 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| coinbase_agentkit_alith-0.2.0.tar.gz | 2.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| coinbase_agentkit_alith-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.8 kB
Release files / coinbase_agentkit_alith-0.2.0.tar.gz
| Download URL | coinbase_agentkit_alith-0.2.0.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4f86d64b820918ac1e960b72f927df357b520c990e8591dc8b0b5e7c3f7787c
|
|
BLAKE2b-256 checksum How to use checksums |
060d1bb490faf29d051e0a8198ecde00ba5c25021f72211a258a5c446e058378
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / coinbase_agentkit_alith-0.2.0-py3-none-any.whl
| Download URL | coinbase_agentkit_alith-0.2.0-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b443c47e6f333cb8c476b99fdd98cfb0cda24377fe67aaec5c2be5ceb1e84c48
|
|
BLAKE2b-256 checksum How to use checksums |
ccdfe52f59f1d9744eb4389984f7c4f39be8ecfcfacb9134f8ea31c999c19a95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|