Smolagents Adapter for GOAT
Integrate the more than +200 onchain tools of GOAT with Smolagents, a framework for building agentic systems with small language models.
Installation
poetry add goat-sdk-adapter-smolagents
Usage
# --- Setup GOAT Wallet and Plugins (Example: Solana + SPL Token) ---
import os
from dotenv import load_dotenv
from solders.keypair import Keypair
from solana.rpc.api import Client as SolanaClient
from goat_plugins.spl_token import spl_token, SplTokenPluginOptions
from goat_plugins.spl_token.tokens import SPL_TOKENS
from goat_wallets.solana import solana
# Load environment variables
load_dotenv()
solana_rpc_endpoint = os.getenv("SOLANA_RPC_ENDPOINT")
solana_wallet_seed = os.getenv("SOLANA_WALLET_SEED")
openai_api_key = os.getenv("OPENAI_API_KEY")
# Make sure environment variables are set
if not solana_rpc_endpoint or not solana_wallet_seed:
raise ValueError("SOLANA_RPC_ENDPOINT and SOLANA_WALLET_SEED must be set in .env")
if not openai_api_key:
raise ValueError("OPENAI_API_KEY must be set in .env to use GPT-4o")
client = SolanaClient(solana_rpc_endpoint)
keypair = Keypair.from_base58_string(solana_wallet_seed)
wallet = solana(client, keypair)
spl_token_plugin = spl_token(SplTokenPluginOptions(
network="mainnet",
tokens=SPL_TOKENS
))
# --- Import Smolagents and the GOAT Adapter ---
from smolagents import OpenAIServerModel, ToolCallingAgent
from goat_adapters.smolagents import get_smolagents_tools
# --- Generate Smolagents Tools from GOAT ---
goat_smolagents_tools = get_smolagents_tools(
wallet=wallet,
plugins=[spl_token_plugin]
)
# --- Define Smolagents Agent using GOAT Tools ---
model = OpenAIServerModel(
model_id="gpt-4o",
)
agent = ToolCallingAgent(
tools=goat_smolagents_tools,
model=model,
add_base_tools=False # Don't include Smolagents default tools
)
# Set custom system prompt
agent.prompt_templates["system_prompt"] = (
"You are an expert analyst focused on the Solana blockchain and its SPL token ecosystem. "
"You have access to specialized tools that can query SPL token balances and potentially other relevant information directly from the blockchain. "
"Your task is to understand the user's question, use the appropriate tool(s) if necessary, and provide a clear, concise answer."
)
# --- Run the agent with a specific task ---
result = agent.run("What is the balance of USDC for my wallet?")
print(result)
Tool Collection
You can also create a Smolagents ToolCollection to manage your GOAT tools:
from smolagents import ToolCollection, ToolCallingAgent
# Create the tools first
goat_tools = get_smolagents_tools(wallet=wallet, plugins=[spl_token_plugin])
# Create a custom tool collection with your GOAT tools
my_tool_collection = ToolCollection(
tools=goat_tools
)
# Now use this collection with your agent
agent = ToolCallingAgent(
tools=my_tool_collection.tools,
model=model,
add_base_tools=False
)
Metadata
Release files for goat-sdk-adapter-smolagents 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| goat_sdk_adapter_smolagents-0.1.0.tar.gz | 4.1 kB | Without provenance | Details for goat_sdk_adapter_smolagents-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| goat_sdk_adapter_smolagents-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for goat_sdk_adapter_smolagents-0.1.0-py3-none-any.whl |
Total release size: 8.7 kB
Release files / goat_sdk_adapter_smolagents-0.1.0.tar.gz
| Download URL | goat_sdk_adapter_smolagents-0.1.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa40a25d2963afa4c0052d5054244b07ef595276ea4c5c8929b0d7b4c48aa3fa
|
|
BLAKE2b-256 checksum How to use checksums |
1fab5d11971ab59cab3025d44fcb55a47b8cc0c333f2c61a1c014a57506799ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.16 Linux/6.8.0-1021-azure
|
Release files / goat_sdk_adapter_smolagents-0.1.0-py3-none-any.whl
| Download URL | goat_sdk_adapter_smolagents-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1cb4ecf80d2696cde9b0db57ee557ee848b8755a4b49b749420a348cbabc1a1
|
|
BLAKE2b-256 checksum How to use checksums |
652c99ad85342168477b4a188a2b868a4a7668323eeeced3820bc5e837cfd0f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.16 Linux/6.8.0-1021-azure
|
Security for goat-sdk-adapter-smolagents 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.