mezoAgent 0.7.3__py3-none-any.whl → 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mezoAgent-0.7.3.dist-info → mezoAgent-0.8.0.dist-info}/METADATA +1 -1
- {mezoAgent-0.7.3.dist-info → mezoAgent-0.8.0.dist-info}/RECORD +8 -7
- mezo_agent/__init__.py +6 -11
- mezo_agent/parsing.py +3 -3
- mezo_agent/safe_mode_btc_tool.py +87 -0
- mezo_agent/token_balance_tool.py +1 -1
- {mezoAgent-0.7.3.dist-info → mezoAgent-0.8.0.dist-info}/WHEEL +0 -0
- {mezoAgent-0.7.3.dist-info → mezoAgent-0.8.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,11 @@
|
|
1
|
-
mezo_agent/__init__.py,sha256=
|
1
|
+
mezo_agent/__init__.py,sha256=fxRf_Z-SEitzT7dp3V0DWmi3nO8yOrb26Avl3kib4QA,795
|
2
2
|
mezo_agent/characters.py,sha256=wub7y9BrAAdAKWwcNAdgrvhRi2zHMaZNzTr2y3qtbsw,515
|
3
3
|
mezo_agent/chat.py,sha256=ZtNurUDV7UzJjbFyU96DNGy37hO3gl0osn19mRu7ER8,859
|
4
4
|
mezo_agent/config.py,sha256=6xFgk80eiBLTasKGW73Ne8hNhMtx8BbQ_Ef79YOyDlc,3233
|
5
|
-
mezo_agent/parsing.py,sha256=
|
5
|
+
mezo_agent/parsing.py,sha256=PeR1R6gqzM9VXt7OdWANDoL7GbzMMRjKLzuP10uugEs,5101
|
6
|
+
mezo_agent/safe_mode_btc_tool.py,sha256=6e8P00Mk570qfPpEiUdMmfvhN3hnHLyOAKrYHu89v4g,3410
|
6
7
|
mezo_agent/swap_musd_btc.py,sha256=Co-XcfK73spm94VC6qzGY0VYoGwsMDKKHM8ToGh2JxU,4289
|
7
|
-
mezo_agent/token_balance_tool.py,sha256=
|
8
|
+
mezo_agent/token_balance_tool.py,sha256=zOjDJdfYT6LuQzPuAxxNeee1srsepevE71fqboiDSWI,1422
|
8
9
|
mezo_agent/token_price_tool.py,sha256=vD-ukq0D_4zmjIy9bZ9qL44nGctf-hWzkQuTd-0wy2U,930
|
9
10
|
mezo_agent/token_utils.py,sha256=3NH_Z_vbZ0uupuuGjEbmwsbUkubluQbL-0xR9kia7nU,1118
|
10
11
|
mezo_agent/transaction.py,sha256=YpfWrkEaf0YGM_Kc4cFwlT9GmBGZkeJHWm0VGHs9Gks,4199
|
@@ -12,7 +13,7 @@ mezo_agent/twitter_client.py,sha256=Va8ZQaK5lZjJUq3-bhIJWnDmX4Mmt4kWRW3aKSGbLq8,
|
|
12
13
|
mezo_agent/twitter_manager.py,sha256=KvxiMOhBmQbLuLoVrAQ77DpAnFIdiDSztsKbZ_3-ar4,2363
|
13
14
|
mezo_agent/utils.py,sha256=hsGtL_iXvUVGnY5aHPQ0v6Jejxd4P4qw0yOtS1omToU,1397
|
14
15
|
mezo_agent/data/new_router.json,sha256=A8U-NVfe1F-hDyR90_SuH8jDAxmzyyHWdJW62j9TZsc,26756
|
15
|
-
mezoAgent-0.
|
16
|
-
mezoAgent-0.
|
17
|
-
mezoAgent-0.
|
18
|
-
mezoAgent-0.
|
16
|
+
mezoAgent-0.8.0.dist-info/METADATA,sha256=xRxuyZCpP3HcmYhcdGFDnWIZdzSM-zX0c8qm-A_nn_g,273
|
17
|
+
mezoAgent-0.8.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
18
|
+
mezoAgent-0.8.0.dist-info/top_level.txt,sha256=rrAci_NyTR9z6w_BrQhQrAhzMW_A0NYhVa0x2USl0nQ,11
|
19
|
+
mezoAgent-0.8.0.dist-info/RECORD,,
|
mezo_agent/__init__.py
CHANGED
@@ -2,14 +2,10 @@ from .transaction import mezo_agent_transaction_btc, mezo_agent_musd_transaction
|
|
2
2
|
from .swap_musd_btc import mezo_agent_swap_musd_btc
|
3
3
|
from .chat import mezo_character_chat
|
4
4
|
from .characters import get_character_prompt
|
5
|
-
from .token_balance_tool import mezo_agent_token_balance_tool
|
6
|
-
from .token_price_tool import mezo_agent_token_price_tool
|
7
|
-
|
8
|
-
|
9
|
-
# ✅ Move TwitterManager import inside a function to avoid circular import
|
10
|
-
def get_twitter_manager():
|
11
|
-
from .twitter_manager import TwitterManager
|
12
|
-
return TwitterManager
|
5
|
+
from .tools.token_balance_tool import mezo_agent_token_balance_tool
|
6
|
+
from .tools.token_price_tool import mezo_agent_token_price_tool
|
7
|
+
# Import the new Safe Mode BTC Transaction Tool
|
8
|
+
from .tools.safe_mode_btc_tool import mezo_agent_safe_mode_btc_transaction
|
13
9
|
|
14
10
|
__all__ = [
|
15
11
|
"mezo_agent_transaction_btc",
|
@@ -18,7 +14,6 @@ __all__ = [
|
|
18
14
|
"mezo_character_chat",
|
19
15
|
"mezo_agent_token_balance_tool",
|
20
16
|
"mezo_agent_token_price_tool",
|
21
|
-
"
|
22
|
-
"get_twitter_manager",
|
17
|
+
"mezo_agent_safe_mode_btc_transaction", # Expose new tool
|
23
18
|
"get_character_prompt"
|
24
|
-
]
|
19
|
+
]
|
mezo_agent/parsing.py
CHANGED
@@ -3,7 +3,7 @@ from langchain.prompts import PromptTemplate
|
|
3
3
|
from langchain_openai import ChatOpenAI
|
4
4
|
from .config import OPENAI_API_KEY
|
5
5
|
|
6
|
-
# Define the expected response schema
|
6
|
+
# Define the expected response schema for extracting transaction details
|
7
7
|
response_schemas = [
|
8
8
|
ResponseSchema(name="amount", description="The amount of cryptocurrency to transfer."),
|
9
9
|
ResponseSchema(name="currency", description="The cryptocurrency (BTC or mUSD)."),
|
@@ -64,7 +64,7 @@ def extract_swap_details(prompt: str):
|
|
64
64
|
except Exception as e:
|
65
65
|
return f"Failed to extract swap details: {str(e)}"
|
66
66
|
|
67
|
-
#
|
67
|
+
#Balance check parsing
|
68
68
|
|
69
69
|
balance_response_schema = [
|
70
70
|
ResponseSchema(name="token_symbol", description="The token symbol to check the balance for (e.g., 'MUSD').")
|
@@ -93,7 +93,7 @@ def extract_balance_details(prompt: str):
|
|
93
93
|
except Exception as e:
|
94
94
|
return f"Failed to extract balance details: {str(e)}"
|
95
95
|
|
96
|
-
#Price parsing
|
96
|
+
#Price parsing
|
97
97
|
price_response_schema = [
|
98
98
|
ResponseSchema(name="token_symbol", description="The token symbol to check the price for (e.g., 'LIMPETH').")
|
99
99
|
]
|
@@ -0,0 +1,87 @@
|
|
1
|
+
from langchain.tools import tool
|
2
|
+
from web3.exceptions import Web3Exception
|
3
|
+
import json
|
4
|
+
from mezo_agent.config import web3_instance, sender_address, account
|
5
|
+
from mezo_agent.parsing import extract_transaction_details
|
6
|
+
from mezo_agent.utils import llm # If you store your ChatOpenAI instance in utils.py
|
7
|
+
|
8
|
+
@tool
|
9
|
+
def mezo_agent_safe_mode_btc_transaction(prompt: str, confirm_before_sending: bool = True) -> str:
|
10
|
+
"""
|
11
|
+
Sends BTC on Mezo Matsnet with a Human-in-the-Loop confirmation step.
|
12
|
+
1) Parses user prompt for transaction details.
|
13
|
+
2) Calls LLM to provide a verbose explanation of the transaction data.
|
14
|
+
3) Shows both raw data and LLM explanation to the user.
|
15
|
+
4) Prompts user for confirmation before broadcasting.
|
16
|
+
"""
|
17
|
+
|
18
|
+
# 1) Parse transaction details
|
19
|
+
transaction_details = extract_transaction_details(prompt)
|
20
|
+
if isinstance(transaction_details, str):
|
21
|
+
return transaction_details # Return parsing error if any
|
22
|
+
|
23
|
+
amount = float(transaction_details["amount"])
|
24
|
+
currency = transaction_details["currency"].lower()
|
25
|
+
recipient = transaction_details["recipient"]
|
26
|
+
|
27
|
+
if currency != "btc":
|
28
|
+
return "❌ This function only handles BTC transactions."
|
29
|
+
|
30
|
+
# 2) Convert to Wei (Mezo uses 18 decimals for BTC)
|
31
|
+
amount_wei = web3_instance.to_wei(amount, "ether")
|
32
|
+
|
33
|
+
# 3) Build transaction (do NOT send yet)
|
34
|
+
nonce = web3_instance.eth.get_transaction_count(sender_address)
|
35
|
+
gas_price = web3_instance.eth.gas_price
|
36
|
+
gas_limit = web3_instance.eth.estimate_gas({"to": recipient, "value": amount_wei, "from": sender_address})
|
37
|
+
|
38
|
+
tx_data = {
|
39
|
+
"to": recipient,
|
40
|
+
"value": amount_wei,
|
41
|
+
"gas": gas_limit,
|
42
|
+
"gasPrice": gas_price,
|
43
|
+
"nonce": nonce,
|
44
|
+
"chainId": 31611, # Mezo Testnet Chain ID
|
45
|
+
}
|
46
|
+
|
47
|
+
# 4) Generate a LLM Explanation
|
48
|
+
analysis_prompt = f"""
|
49
|
+
You are given the following transaction data on Mezo Matsnet:
|
50
|
+
- Recipient: {recipient}
|
51
|
+
- Amount (BTC): {amount}
|
52
|
+
- Gas Price: {gas_price}
|
53
|
+
- Gas Limit: {gas_limit}
|
54
|
+
- Nonce: {nonce}
|
55
|
+
- Chain ID: 31611 (Mezo Testnet)
|
56
|
+
|
57
|
+
Explain these details in a user-friendly way, covering:
|
58
|
+
1. The purpose of each field (nonce, gas, etc.).
|
59
|
+
2. Potential fees (approximate cost) or any known risks.
|
60
|
+
3. A short summary of what will happen if the user confirms.
|
61
|
+
|
62
|
+
Use a concise and helpful tone.
|
63
|
+
"""
|
64
|
+
analysis_response = llm.invoke(analysis_prompt)
|
65
|
+
explanation_text = analysis_response.content if analysis_response else "❌ LLM explanation unavailable."
|
66
|
+
|
67
|
+
# 5) Show user raw data & explanation, confirm
|
68
|
+
if confirm_before_sending:
|
69
|
+
print("\n--- BTC Transaction Data ---")
|
70
|
+
print(json.dumps(tx_data, indent=2))
|
71
|
+
print("----------------------------")
|
72
|
+
|
73
|
+
print("\n--- LLM Analysis ---")
|
74
|
+
print(explanation_text)
|
75
|
+
print("--------------------")
|
76
|
+
|
77
|
+
choice = input("Do you want to proceed with this BTC transaction? [y/n]: ").strip().lower()
|
78
|
+
if choice != 'y':
|
79
|
+
return "❌ Transaction aborted by user."
|
80
|
+
|
81
|
+
# 6) Sign & send
|
82
|
+
try:
|
83
|
+
signed_tx = account.sign_transaction(tx_data)
|
84
|
+
tx_hash = web3_instance.eth.send_raw_transaction(signed_tx.rawTransaction)
|
85
|
+
return f"✅ BTC transaction successful! Hash: {tx_hash.hex()}"
|
86
|
+
except Web3Exception as e:
|
87
|
+
return f"❌ Transaction failed: {str(e)}"
|
mezo_agent/token_balance_tool.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from langchain.tools import tool
|
2
2
|
from mezo_agent.config import web3_instance, sender_address, ERC20_ABI
|
3
3
|
from mezo_agent.parsing import extract_balance_details
|
4
|
-
from mezo_agent.token_utils import get_token_address_by_symbol
|
4
|
+
from mezo_agent.token_utils import get_token_address_by_symbol
|
5
5
|
|
6
6
|
@tool
|
7
7
|
def mezo_agent_token_balance_tool(balance_prompt: str) -> str:
|
File without changes
|
File without changes
|