mezoAgent 0.5.4__py3-none-any.whl → 0.6.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mezoAgent
3
- Version: 0.5.4
3
+ Version: 0.6.1
4
4
  Summary: A Python package for Mezo Agent transactions with LangChain tools
5
5
  Author: Dreadwulf, Duck, Digi
6
6
  Requires-Dist: python-dotenv
@@ -2,13 +2,14 @@ mezo_agent/__init__.py,sha256=naG5ZIXKDWTRlqdx2oi1zJcRZpJBO9ugVkW0MaPkZuk,497
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=v5AiLfZ8Rvm46gek7QX2OmeLFO8xhvQOH_yCc6GNlLA,3850
5
+ mezo_agent/parsing.py,sha256=dnS5Qw9V8qvSA_IPgn6nCUnyEfZP9TphO8DnH8oUuiM,5080
6
6
  mezo_agent/swap_musd_btc.py,sha256=Co-XcfK73spm94VC6qzGY0VYoGwsMDKKHM8ToGh2JxU,4289
7
- mezo_agent/token_balance_tool.py,sha256=OvdpEr3Vy_LU1-dg2hOt4IJR6B8Rmql_NQCuVy3cqqg,1459
7
+ mezo_agent/token_balance_tool.py,sha256=vWWvZxJWPFX05ENIcr5mCwW6r8OVzV21iDrXRKkRBRc,1463
8
+ mezo_agent/token_price_tool.py,sha256=MAJsRv0xJcmpIatxoXI6_hoBPVPXcJMEyzSoX-p9l-Q,916
8
9
  mezo_agent/transaction.py,sha256=YpfWrkEaf0YGM_Kc4cFwlT9GmBGZkeJHWm0VGHs9Gks,4199
9
- mezo_agent/utils.py,sha256=SnVRjAdrluqiiTjPNi0VhMKGGRvmYZlPXE5B4Bknq8c,1106
10
+ mezo_agent/utils.py,sha256=XRq--PRJbWlG9kpz99QHWu7mLpYY4MYblm38U1xK4YE,2381
10
11
  mezo_agent/data/new_router.json,sha256=A8U-NVfe1F-hDyR90_SuH8jDAxmzyyHWdJW62j9TZsc,26756
11
- mezoAgent-0.5.4.dist-info/METADATA,sha256=djvkoN-W3_Gl04MEOu62OXfP9hxExBwA4SadY8iKkeQ,273
12
- mezoAgent-0.5.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
13
- mezoAgent-0.5.4.dist-info/top_level.txt,sha256=rrAci_NyTR9z6w_BrQhQrAhzMW_A0NYhVa0x2USl0nQ,11
14
- mezoAgent-0.5.4.dist-info/RECORD,,
12
+ mezoAgent-0.6.1.dist-info/METADATA,sha256=g1ynqIcb6yxweH0v-kFIBtS9nFgnsUVI7jtBj_bGNec,273
13
+ mezoAgent-0.6.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
+ mezoAgent-0.6.1.dist-info/top_level.txt,sha256=rrAci_NyTR9z6w_BrQhQrAhzMW_A0NYhVa0x2USl0nQ,11
15
+ mezoAgent-0.6.1.dist-info/RECORD,,
mezo_agent/parsing.py CHANGED
@@ -91,4 +91,37 @@ def extract_balance_details(prompt: str):
91
91
  try:
92
92
  return balance_output_parser.parse(response.content)
93
93
  except Exception as e:
94
- return f"Failed to extract balance details: {str(e)}"
94
+ return f"Failed to extract balance details: {str(e)}"
95
+
96
+ #Price parsing tools
97
+ price_response_schema = [
98
+ ResponseSchema(name="token_symbol", description="The token symbol to check the price for (e.g., 'LIMPETH').")
99
+ ]
100
+ price_output_parser = StructuredOutputParser.from_response_schemas(price_response_schema)
101
+
102
+ price_prompt_template = PromptTemplate(
103
+ template="""Output a JSON object with the following key:
104
+ - token_symbol: (string) The token symbol for which to check the price (e.g., "LIMPETH").
105
+
106
+ Extract this detail from the following request:
107
+ {input}
108
+
109
+ Your output must be a valid JSON object with no additional text.
110
+ """,
111
+ input_variables=["input"],
112
+ )
113
+
114
+ def extract_price_details(prompt: str):
115
+ """
116
+ Parses a price query and extracts the token symbol.
117
+
118
+ :param prompt: User input asking for a token price.
119
+ :return: Dictionary containing the token symbol or an error message.
120
+ """
121
+ formatted_prompt = price_prompt_template.format(input=prompt)
122
+ response = llm.invoke(formatted_prompt)
123
+ print("LLM raw price response:", response.content) # Debugging
124
+ try:
125
+ return price_output_parser.parse(response.content)
126
+ except Exception as e:
127
+ return f"❌ Failed to extract price details: {str(e)}"
@@ -1,7 +1,6 @@
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.utils import get_token_address_by_symbol
5
4
 
6
5
  @tool
7
6
  def mezo_agent_token_balance_tool(balance_prompt: str) -> str:
@@ -11,6 +10,7 @@ def mezo_agent_token_balance_tool(balance_prompt: str) -> str:
11
10
  :param balance_prompt: User query containing the token symbol.
12
11
  :return: Token balance for the sender's address.
13
12
  """
13
+ from mezo_agent.utils import get_token_address_by_symbol
14
14
  details = extract_balance_details(balance_prompt)
15
15
 
16
16
  if isinstance(details, str): # Handle extraction errors
@@ -0,0 +1,28 @@
1
+ from langchain.tools import tool
2
+ from mezo_agent.config import query_graph
3
+ from mezo_agent.parsing import extract_price_details
4
+
5
+ @tool
6
+ def mezo_agent_token_price_tool(price_prompt: str) -> str:
7
+ """
8
+ Queries the price of a specified token in USD and ETH on Mezo Matsnet.
9
+
10
+ :param price_prompt: User query containing the token symbol.
11
+ :return: Token price details.
12
+
13
+ """
14
+ from mezo_agent.utils import get_token_price
15
+ details = extract_price_details(price_prompt)
16
+
17
+ if isinstance(details, str): # Handle extraction errors
18
+ return details
19
+
20
+ token_symbol = details.get("token_symbol")
21
+ if not token_symbol:
22
+ return "❌ Could not extract token symbol for price query."
23
+
24
+ try:
25
+ # Get the token price
26
+ return get_token_price(token_symbol)
27
+ except Exception as e:
28
+ return f"❌ Failed to fetch token price: {str(e)}"
mezo_agent/utils.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from mezo_agent.config import web3_instance, query_graph
2
+ from mezo_agent.utils import get_token_address_by_symbol
2
3
 
3
4
  def get_token_address_by_symbol(symbol: str) -> str:
4
5
  """
@@ -28,4 +29,42 @@ def get_token_address_by_symbol(symbol: str) -> str:
28
29
  return checksum_address
29
30
  else:
30
31
  available_symbols = [t["symbol"] for t in tokens]
31
- raise Exception(f"Token '{symbol}' not found. Available: {', '.join(available_symbols)}")
32
+ raise Exception(f"Token '{symbol}' not found. Available: {', '.join(available_symbols)}")
33
+
34
+
35
+ def get_token_price(token_symbol: str) -> str:
36
+ """
37
+ Fetches the price of a given token in USD and ETH from the Goldsky subgraph.
38
+
39
+ :param token_symbol: The token symbol (e.g., 'MUSD', 'WBTC').
40
+ :return: A formatted string with the token price in USD and ETH.
41
+ """
42
+ if token_symbol.lower() == "btc":
43
+ token_symbol = "wtbtc"
44
+
45
+ try:
46
+ token_address = get_token_address_by_symbol(token_symbol)
47
+ except Exception as e:
48
+ return f"❌ Token lookup error: {e}"
49
+
50
+ token_id = token_address.lower()
51
+ query = f'''
52
+ {{
53
+ token(id: "{token_id}") {{
54
+ id
55
+ decimals
56
+ derivedUSD
57
+ derivedETH
58
+ }}
59
+ }}
60
+ '''
61
+ try:
62
+ result = query_graph(query)
63
+ token_data = result["data"]["token"]
64
+ if token_data is None:
65
+ return f"❌ Price data for token {token_symbol.upper()} not found."
66
+ derivedUSD = token_data.get("derivedUSD", "N/A")
67
+ derivedETH = token_data.get("derivedETH", "N/A")
68
+ return f"✅ Price of {token_symbol.upper()}: {derivedUSD} USD, {derivedETH} ETH."
69
+ except Exception as e:
70
+ return f"❌ Failed to get price data: {e}"