diff --git a/autotx/agents/ExampleAgent.py b/autotx/agents/ExampleAgent.py index 6ad6fe44..0fb5a3cf 100644 --- a/autotx/agents/ExampleAgent.py +++ b/autotx/agents/ExampleAgent.py @@ -4,10 +4,11 @@ name = "example-agent" -system_message = f""" -Example of an agent system message. -... -""" +system_message = dedent(f""" + Example of an agent system message. + ... + """ +) class ExampleTool(AutoTxTool): name: str = "example_tool" @@ -34,7 +35,7 @@ def run( class ExampleAgent(AutoTxAgent): name=name - system_message=dedent(system_message) + system_message=system_message tools=[ ExampleTool(), # AnotherTool(...), diff --git a/autotx/agents/ResearchTokensAgent.py b/autotx/agents/ResearchTokensAgent.py index 9e2d6be4..65d6d483 100644 --- a/autotx/agents/ResearchTokensAgent.py +++ b/autotx/agents/ResearchTokensAgent.py @@ -12,6 +12,16 @@ from autotx.utils.constants import COINGECKO_API_KEY from autotx.utils.ethereum.networks import SUPPORTED_NETWORKS_AS_STRING, ChainId +name = "research-tokens" + +system_message = lambda autotx: dedent(f""" + You are an AI assistant. Assist the user (address: {autotx.manager.address}) in their task of researching tokens. + You are an expert in Ethereum tokens and can help users research tokens. + You use the tools available to assist the user in their tasks. + Retrieve token information, get token price, market cap, and price change percentage + """ +) + COINGECKO_NETWORKS_TO_SUPPORTED_NETWORKS_MAP = { ChainId.MAINNET: "ethereum", ChainId.OPTIMISM: "optimistic-ethereum", @@ -241,13 +251,8 @@ def run( return run class ResearchTokensAgent(AutoTxAgent): - name = "research-tokens" - system_message = lambda autotx: f""" - You are an AI assistant. Assist the user (address: {autotx.manager.address}) in their task of researching tokens. - You are an expert in Ethereum tokens and can help users research tokens. - You use the tools available to assist the user in their tasks. - Retrieve token information, get token price, market cap, and price change percentage - """ + name = name + system_message = system_message tools = [ GetTokenInformationTool(), SearchTokenTool(), diff --git a/autotx/agents/SendTokensAgent.py b/autotx/agents/SendTokensAgent.py index bf7cf96d..4a00255f 100644 --- a/autotx/agents/SendTokensAgent.py +++ b/autotx/agents/SendTokensAgent.py @@ -13,6 +13,17 @@ from web3.constants import ADDRESS_ZERO from autotx.utils.ethereum.eth_address import ETHAddress +name = "send-tokens" + +system_message = lambda autotx: dedent(f""" + You are an AI assistant. Assist the user (address: {autotx.manager.address}) in their tasks by fetching balances and preparing transactions to send tokens. + You are an expert in Ethereum tokens and can help users send tokens and check their balances. + You use the tools available to assist the user in their tasks. + Your job is to only prepare the transactions and the user will take care of executing them. + NOTE: There is no reason to call get_erc20_balance after calling transfer as the transfers are only prepared and not executed. + """ +) + class TransferETHTool(AutoTxTool): name: str = "prepare_transfer_eth_transaction" description: str = dedent( @@ -124,16 +135,8 @@ def run( return run class SendTokensAgent(AutoTxAgent): - name: str = "send-tokens" - system_message: Callable[[AutoTx], str] = lambda autotx: dedent( - f""" - You are an AI assistant. Assist the user (address: {autotx.manager.address}) in their tasks by fetching balances and preparing transactions to send tokens. - You are an expert in Ethereum tokens and can help users send tokens and check their balances. - You use the tools available to assist the user in their tasks. - Your job is to only prepare the transactions and the user will take care of executing them. - NOTE: There is no reason to call get_erc20_balance after calling transfer as the transfers are only prepared and not executed. - """ - ) + name = name + system_message = system_message tools = [ TransferETHTool(), TransferERC20Tool(), diff --git a/autotx/agents/SwapTokensAgent.py b/autotx/agents/SwapTokensAgent.py index c2550987..fd8c0425 100644 --- a/autotx/agents/SwapTokensAgent.py +++ b/autotx/agents/SwapTokensAgent.py @@ -7,6 +7,33 @@ from autotx.utils.ethereum.uniswap.swap import SUPPORTED_UNISWAP_V3_NETWORKS, build_swap_transaction from gnosis.eth import EthereumNetworkNotSupported as ChainIdNotSupported +name = "swap-tokens" + +system_message = lambda autotx: dedent(f""" + You are an expert at buying and selling tokens. Assist the user (address: {autotx.manager.address}) in their task of swapping tokens. + You use the tools available to assist the user in their tasks. + Perform token swaps, manage liquidity, and query pool statistics on the Uniswap protocol + An autonomous agent skilled in Ethereum blockchain interactions, specifically tailored for the Uniswap V3 protocol. + Note a balance of a token is not required to perform a swap, if there is an earlier prepared transaction that will provide the token. + Examples: + {{ + "token_to_sell": "5 ETH", + "token_to_buy": "USDC" + }} // Prepares a swap transaction to sell 5 ETH and buy USDC + + {{ + "token_to_sell": "ETH", + "token_to_buy": "5 USDC" + }} // Prepares a swap transaction to sell ETH and buy 5 USDC + + Invalid Example: + {{ + "token_to_sell": "5 ETH", + "token_to_buy": "5 USDC" + }} // Invalid input. Only one token amount should be provided, not both. + """ +) + def get_tokens_address(token_in: str, token_out: str, network_info: NetworkInfo): token_in = token_in.lower() token_out = token_out.lower() @@ -80,31 +107,8 @@ def run( return run class SwapTokensAgent(AutoTxAgent): - name = "swap-tokens" - system_message = lambda autotx: dedent(f""" - You are an expert at buying and selling tokens. Assist the user (address: {autotx.manager.address}) in their task of swapping tokens. - You use the tools available to assist the user in their tasks. - Perform token swaps, manage liquidity, and query pool statistics on the Uniswap protocol - An autonomous agent skilled in Ethereum blockchain interactions, specifically tailored for the Uniswap V3 protocol. - Note a balance of a token is not required to perform a swap, if there is an earlier prepared transaction that will provide the token. - Examples: - {{ - "token_to_sell": "5 ETH", - "token_to_buy": "USDC" - }} // Prepares a swap transaction to sell 5 ETH and buy USDC - - {{ - "token_to_sell": "ETH", - "token_to_buy": "5 USDC" - }} // Prepares a swap transaction to sell ETH and buy 5 USDC - - Invalid Example: - {{ - "token_to_sell": "5 ETH", - "token_to_buy": "5 USDC" - }} // Invalid input. Only one token amount should be provided, not both. - """ - ) + name = name + system_message = system_message tools = [ SwapTool() ]