Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved prompts to top of the agent files #160

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions autotx/agents/ExampleAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,7 +35,7 @@ def run(

class ExampleAgent(AutoTxAgent):
name=name
system_message=dedent(system_message)
system_message=system_message
tools=[
ExampleTool(),
# AnotherTool(...),
Expand Down
19 changes: 12 additions & 7 deletions autotx/agents/ResearchTokensAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down
23 changes: 13 additions & 10 deletions autotx/agents/SendTokensAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(),
Expand Down
54 changes: 29 additions & 25 deletions autotx/agents/SwapTokensAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
]