mezoAgent 0.2.4__py3-none-any.whl → 0.3.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {mezoAgent-0.2.4.dist-info → mezoAgent-0.3.0.dist-info}/METADATA +1 -1
- mezoAgent-0.3.0.dist-info/RECORD +9 -0
- mezo_agent/__init__.py +2 -1
- mezo_agent/config.py +27 -29
- mezo_agent/parsing.py +30 -1
- mezo_agent/swap_musd_btc.py +0 -0
- mezoAgent-0.2.4.dist-info/RECORD +0 -8
- {mezoAgent-0.2.4.dist-info → mezoAgent-0.3.0.dist-info}/WHEEL +0 -0
- {mezoAgent-0.2.4.dist-info → mezoAgent-0.3.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
mezo_agent/__init__.py,sha256=XOJWLvrxgH7jBkKdXFLVGLV2dmCyyRpo8VcjicWBD0I,133
|
2
|
+
mezo_agent/config.py,sha256=2nwNy9Qq1e2y8ISg4uoQUjTChUxfVSuY7CV7ipX8xrQ,1863
|
3
|
+
mezo_agent/parsing.py,sha256=rolPVE8r_RS6BqKe25r1nyZQ47rvTPG2Hv09Kxxfv4c,2821
|
4
|
+
mezo_agent/swap_musd_btc.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
mezo_agent/transaction.py,sha256=YpfWrkEaf0YGM_Kc4cFwlT9GmBGZkeJHWm0VGHs9Gks,4199
|
6
|
+
mezoAgent-0.3.0.dist-info/METADATA,sha256=t5yFwxj1wnYTvmljOIB6Az02BAXDE0vjk1igQAQb0EU,323
|
7
|
+
mezoAgent-0.3.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
+
mezoAgent-0.3.0.dist-info/top_level.txt,sha256=rrAci_NyTR9z6w_BrQhQrAhzMW_A0NYhVa0x2USl0nQ,11
|
9
|
+
mezoAgent-0.3.0.dist-info/RECORD,,
|
mezo_agent/__init__.py
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
from .transaction import mezo_agent_transaction_btc, mezo_agent_musd_transaction
|
1
|
+
from .transaction import mezo_agent_transaction_btc, mezo_agent_musd_transaction
|
2
|
+
from .swap_musd_btc import mezo_agent_swap_musd_btc
|
mezo_agent/config.py
CHANGED
@@ -2,45 +2,43 @@ import os
|
|
2
2
|
import json
|
3
3
|
from dotenv import load_dotenv
|
4
4
|
from web3 import Web3
|
5
|
-
from web3.exceptions import Web3Exception
|
6
5
|
|
7
|
-
#
|
8
|
-
|
9
|
-
USER_ENV_PATH = os.path.join(USER_PROJECT_DIR, ".env")
|
6
|
+
# Load environment variables
|
7
|
+
load_dotenv()
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# Check for keys
|
10
|
+
OpenAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
11
|
+
if not OpenAI_API_KEY:
|
12
|
+
raise ValueError("OPENAI_API_KEY not found in environment variables!")
|
15
13
|
|
16
|
-
# ✅ Load keys from the environment
|
17
14
|
PRIVATE_KEY = os.getenv("PRIVATE_KEY")
|
18
|
-
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
19
|
-
|
20
15
|
if not PRIVATE_KEY:
|
21
|
-
|
22
|
-
PRIVATE_KEY = None # Allow package to be installed but prevent transactions
|
16
|
+
raise ValueError("PRIVATE_KEY not found in environment variables!")
|
23
17
|
|
24
|
-
#
|
18
|
+
# Mezo Testnet RPC and Web3 initialization
|
25
19
|
RPC_URL = "https://rpc.test.mezo.org"
|
26
20
|
web3_instance = Web3(Web3.HTTPProvider(RPC_URL))
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# ✅ Initialize account and sender address
|
32
|
-
if PRIVATE_KEY:
|
33
|
-
account = web3_instance.eth.account.from_key(PRIVATE_KEY)
|
34
|
-
sender_address = account.address
|
35
|
-
else:
|
36
|
-
account = None
|
37
|
-
sender_address = None
|
22
|
+
# Create Account Object
|
23
|
+
account = web3_instance.eth.account.from_key(PRIVATE_KEY)
|
24
|
+
sender_address = account.address
|
38
25
|
|
39
|
-
#
|
26
|
+
# mUSD Contract Setup using approve/allowance ABI
|
40
27
|
MUSD_ADDRESS = "0x637e22A1EBbca50EA2d34027c238317fD10003eB"
|
41
28
|
ERC20_ABI = json.loads(
|
42
|
-
'[{"constant": false, "inputs": [{"name": "
|
43
|
-
'
|
44
|
-
'"
|
29
|
+
'[{"constant": false, "inputs": [{"name": "spender", "type": "address"}, {"name": "amount", "type": "uint256"}],'
|
30
|
+
'"name": "approve", "outputs": [{"name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"},'
|
31
|
+
'{"constant": true, "inputs": [{"name": "owner", "type": "address"}, {"name": "spender", "type": "address"}],'
|
32
|
+
'"name": "allowance", "outputs": [{"name": "remaining", "type": "uint256"}], "stateMutability": "view", "type": "function"}]'
|
45
33
|
)
|
46
|
-
musd_contract = web3_instance.eth.contract(address=MUSD_ADDRESS, abi=ERC20_ABI)
|
34
|
+
musd_contract = web3_instance.eth.contract(address=MUSD_ADDRESS, abi=ERC20_ABI)
|
35
|
+
|
36
|
+
# Wrapped BTC and Swap Router setup
|
37
|
+
WRAPPED_BTC_ADDRESS = "0xA460F83cdd9584E4bD6a9838abb0baC58EAde999"
|
38
|
+
ROUTER_ADDRESS = "0xC2E61936a542D78b9c3AA024fA141c4C632DF6c1"
|
39
|
+
|
40
|
+
# Load router ABI from a JSON file packaged with mezoAgent
|
41
|
+
router_abi_path = os.path.join(os.path.dirname(__file__), "new_router_abi.json")
|
42
|
+
with open(router_abi_path, "r") as f:
|
43
|
+
router_abi = json.load(f)
|
44
|
+
router_contract = web3_instance.eth.contract(address=ROUTER_ADDRESS, abi=router_abi)
|
mezo_agent/parsing.py
CHANGED
@@ -33,4 +33,33 @@ def extract_transaction_details(prompt: str):
|
|
33
33
|
try:
|
34
34
|
return output_parser.parse(response.content)
|
35
35
|
except Exception as e:
|
36
|
-
return f"❌ Failed to extract transaction details: {str(e)}"
|
36
|
+
return f"❌ Failed to extract transaction details: {str(e)}"
|
37
|
+
|
38
|
+
|
39
|
+
swap_response_schemas = [
|
40
|
+
ResponseSchema(name="amount", description="The amount of mUSD to swap."),
|
41
|
+
ResponseSchema(name="from_currency", description="The token to swap from (should always be 'mUSD')."),
|
42
|
+
ResponseSchema(name="to_currency", description="The token to receive (should always be 'BTC')."),
|
43
|
+
ResponseSchema(name="router_address", description="The Dumpy Swap router address for executing the swap."),
|
44
|
+
]
|
45
|
+
swap_output_parser = StructuredOutputParser.from_response_schemas(swap_response_schemas)
|
46
|
+
|
47
|
+
swap_prompt_template = PromptTemplate(
|
48
|
+
template=(
|
49
|
+
"Extract swap transaction details from this request:\n{input}\n\n"
|
50
|
+
"- The token to swap from should always be 'mUSD'.\n"
|
51
|
+
"- The token to receive should always be 'BTC'.\n"
|
52
|
+
"- The router address should always be '0xC2E61936a542D78b9c3AA024fA141c4C632DF6c1'.\n\n"
|
53
|
+
"{format_instructions}"
|
54
|
+
),
|
55
|
+
input_variables=["input"],
|
56
|
+
partial_variables={"format_instructions": swap_output_parser.get_format_instructions()},
|
57
|
+
)
|
58
|
+
|
59
|
+
def extract_swap_details(prompt: str):
|
60
|
+
formatted_prompt = swap_prompt_template.format(input=prompt)
|
61
|
+
response = llm.invoke(formatted_prompt)
|
62
|
+
try:
|
63
|
+
return swap_output_parser.parse(response.content)
|
64
|
+
except Exception as e:
|
65
|
+
return f"Failed to extract swap details: {str(e)}"
|
File without changes
|
mezoAgent-0.2.4.dist-info/RECORD
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
mezo_agent/__init__.py,sha256=lsonH0-yY3Die0cRmiwsPSHwZQDh_UEAVIpc2uwZYIM,80
|
2
|
-
mezo_agent/config.py,sha256=c16-JHEbK5rFBKO-QdxBRtrl4DSlYzGckD9BzbTw2dY,1708
|
3
|
-
mezo_agent/parsing.py,sha256=dFqNHGH0LoG4_TEsHKcorj6aY_Rh4H8f5Yj7ZdfKJzE,1454
|
4
|
-
mezo_agent/transaction.py,sha256=YpfWrkEaf0YGM_Kc4cFwlT9GmBGZkeJHWm0VGHs9Gks,4199
|
5
|
-
mezoAgent-0.2.4.dist-info/METADATA,sha256=ACNVZPv9OaqSgU_81bYj8BDGR3-ze1IPqkH89PEcD0g,323
|
6
|
-
mezoAgent-0.2.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
7
|
-
mezoAgent-0.2.4.dist-info/top_level.txt,sha256=rrAci_NyTR9z6w_BrQhQrAhzMW_A0NYhVa0x2USl0nQ,11
|
8
|
-
mezoAgent-0.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|