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

chore: show error message if something fails in execution #196

Merged
merged 1 commit into from
Apr 11, 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
12 changes: 9 additions & 3 deletions autotx/AutoTx.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def run(self, prompt: str, non_interactive: bool, silent: bool = False) -> None:
Verifier analyzes chat and responds with TERMINATE if the goal is met.
Verifier can consider the goal met if the other agents have prepared the necessary transactions.

If some information needs to be returned to the user, add it in your answer and then say the word TERMINATE.
Make sure to only add information if the user explicitly ask for a question that needs to be answered
If some information needs to be returned to the user or if there are any errors encountered during the process, add this in your answer.
Start any error messages with "ERROR:" to clearly indicate the issue. Then say the word TERMINATE.
Make sure to only add information if the user explicitly asks for a question that needs to be answered
or error details if user's request can not be completed.
"""
),
llm_config=self.get_llm_config(),
Expand Down Expand Up @@ -98,7 +100,11 @@ def run(self, prompt: str, non_interactive: bool, silent: bool = False) -> None:
))

if chat.summary:
cprint(chat.summary.replace("\n", ""), "green")
if "ERROR:" in chat.summary:
error_message = chat.summary.replace("ERROR: ", "").replace("\n", "")
cprint(error_message, "red")
else:
cprint(chat.summary.replace("\n", ""), "green")

try:
self.manager.send_tx_batch(self.transactions, require_approval=not non_interactive)
Expand Down
6 changes: 3 additions & 3 deletions autotx/agents/SwapTokensAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def get_tokens_address(token_in: str, token_out: str, network_info: NetworkInfo)

if not network_info.chain_id in SUPPORTED_UNISWAP_V3_NETWORKS:
raise ChainIdNotSupported(
f"Network {network_info.chain_id.name} not supported for swap"
f"Network {network_info.chain_id.name.lower()} not supported for swap"
)

if token_in not in network_info.tokens:
raise Exception(f"Token {token_in} is not supported")
raise Exception(f"Token {token_in} is not supported in network {network_info.chain_id.name.lower()}")

if token_out not in network_info.tokens:
raise Exception(f"Token {token_out} is not supported")
raise Exception(f"Token {token_out} is not supported in network {network_info.chain_id.name.lower()}")

return (network_info.tokens[token_in], network_info.tokens[token_out])

Expand Down
Loading