mezoAgent 0.6.4__tar.gz → 0.7.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. {mezoagent-0.6.4 → mezoagent-0.7.0}/PKG-INFO +1 -1
  2. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezoAgent.egg-info/PKG-INFO +1 -1
  3. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezoAgent.egg-info/SOURCES.txt +2 -0
  4. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/__init__.py +3 -1
  5. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/token_balance_tool.py +2 -1
  6. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/token_price_tool.py +2 -3
  7. mezoagent-0.7.0/mezo_agent/token_utils.py +32 -0
  8. mezoagent-0.7.0/mezo_agent/twitter_client.py +78 -0
  9. mezoagent-0.7.0/mezo_agent/utils.py +39 -0
  10. {mezoagent-0.6.4 → mezoagent-0.7.0}/setup.py +1 -1
  11. mezoagent-0.6.4/mezo_agent/utils.py +0 -70
  12. {mezoagent-0.6.4 → mezoagent-0.7.0}/MANIFEST.in +0 -0
  13. {mezoagent-0.6.4 → mezoagent-0.7.0}/README.md +0 -0
  14. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezoAgent.egg-info/dependency_links.txt +0 -0
  15. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezoAgent.egg-info/requires.txt +0 -0
  16. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezoAgent.egg-info/top_level.txt +0 -0
  17. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/characters.py +0 -0
  18. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/chat.py +0 -0
  19. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/config.py +0 -0
  20. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/data/new_router.json +0 -0
  21. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/parsing.py +0 -0
  22. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/swap_musd_btc.py +0 -0
  23. {mezoagent-0.6.4 → mezoagent-0.7.0}/mezo_agent/transaction.py +0 -0
  24. /mezoagent-0.6.4/mezo_agent/token_utils.py → /mezoagent-0.7.0/mezo_agent/twitter_manager.py +0 -0
  25. {mezoagent-0.6.4 → mezoagent-0.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mezoAgent
3
- Version: 0.6.4
3
+ Version: 0.7.0
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mezoAgent
3
- Version: 0.6.4
3
+ Version: 0.7.0
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
@@ -16,5 +16,7 @@ mezo_agent/token_balance_tool.py
16
16
  mezo_agent/token_price_tool.py
17
17
  mezo_agent/token_utils.py
18
18
  mezo_agent/transaction.py
19
+ mezo_agent/twitter_client.py
20
+ mezo_agent/twitter_manager.py
19
21
  mezo_agent/utils.py
20
22
  mezo_agent/data/new_router.json
@@ -4,7 +4,8 @@ from .chat import mezo_character_chat
4
4
  from .characters import get_character_prompt
5
5
  from .token_balance_tool import mezo_agent_token_balance_tool
6
6
  from .token_price_tool import mezo_agent_token_price_tool
7
- from .token_utils import get_token_address_by_symbol # ✅ Expose new module
7
+ from .token_utils import get_token_address_by_symbol
8
+ from .twitter_manager import TwitterManager
8
9
 
9
10
  __all__ = [
10
11
  "mezo_agent_transaction_btc",
@@ -14,5 +15,6 @@ __all__ = [
14
15
  "mezo_agent_token_balance_tool",
15
16
  "mezo_agent_token_price_tool",
16
17
  "get_token_address_by_symbol",
18
+ "TwitterManager",
17
19
  "get_character_prompt"
18
20
  ]
@@ -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 # ✅ Import from new module
4
+ from mezo_agent.token_utils import get_token_address_by_symbol # ✅ Correct import
5
5
 
6
6
  @tool
7
7
  def mezo_agent_token_balance_tool(balance_prompt: str) -> str:
@@ -33,3 +33,4 @@ def mezo_agent_token_balance_tool(balance_prompt: str) -> str:
33
33
  return f"✅ {token_symbol.upper()} Balance: {balance}"
34
34
  except Exception as e:
35
35
  return f"❌ Failed to fetch balance: {str(e)}"
36
+
@@ -1,7 +1,7 @@
1
1
  from langchain.tools import tool
2
2
  from mezo_agent.config import query_graph
3
3
  from mezo_agent.parsing import extract_price_details
4
- from mezo_agent.token_utils import get_token_address_by_symbol # ✅ Import from new module
4
+ from mezo_agent.utils import get_token_price # ✅ Correct import
5
5
 
6
6
  @tool
7
7
  def mezo_agent_token_price_tool(price_prompt: str) -> str:
@@ -11,8 +11,6 @@ def mezo_agent_token_price_tool(price_prompt: str) -> str:
11
11
  :param price_prompt: User query containing the token symbol.
12
12
  :return: Token price details.
13
13
  """
14
- from mezo_agent.utils import get_token_price # ✅ Import moved inside function
15
-
16
14
  details = extract_price_details(price_prompt)
17
15
 
18
16
  if isinstance(details, str): # Handle extraction errors
@@ -27,3 +25,4 @@ def mezo_agent_token_price_tool(price_prompt: str) -> str:
27
25
  return get_token_price(token_symbol)
28
26
  except Exception as e:
29
27
  return f"❌ Failed to fetch token price: {str(e)}"
28
+
@@ -0,0 +1,32 @@
1
+ from mezo_agent.config import query_graph, web3_instance
2
+
3
+ def get_token_address_by_symbol(symbol: str) -> str:
4
+ """
5
+ Fetches the token contract address dynamically from the Goldsky subgraph.
6
+ :param symbol: Token symbol (e.g., 'MUSD', 'WBTC').
7
+ :return: Ethereum checksum address of the token.
8
+ """
9
+ if symbol.lower() == "btc":
10
+ symbol = "wtbtc"
11
+
12
+ query_all = '''
13
+ {
14
+ tokens(first: 100) {
15
+ id
16
+ symbol
17
+ }
18
+ }
19
+ '''
20
+ data = query_graph(query_all)
21
+ tokens = data.get("data", {}).get("tokens", [])
22
+
23
+ matching_tokens = [t for t in tokens if t["symbol"].lower() == symbol.lower()]
24
+
25
+ if matching_tokens:
26
+ token_address = matching_tokens[0]["id"]
27
+ checksum_address = web3_instance.to_checksum_address(token_address)
28
+ print(f"✅ Token {symbol} found at address: {checksum_address}") # Debugging
29
+ return checksum_address
30
+ else:
31
+ available_symbols = [t["symbol"] for t in tokens]
32
+ raise Exception(f"❌ Token '{symbol}' not found. Available: {', '.join(available_symbols)}")
@@ -0,0 +1,78 @@
1
+ import tweepy
2
+ import time
3
+ import random
4
+ from datetime import datetime, timedelta
5
+ from threading import Thread
6
+ from mezo_agent.config import load_dotenv
7
+ import os
8
+
9
+ # Load environment variables
10
+ load_dotenv()
11
+
12
+ class TwitterClient:
13
+ """
14
+ A modular Twitter client for MezoAgent that allows characters to tweet automatically.
15
+ """
16
+
17
+ def __init__(self, character_name: str, api_key: str, api_secret: str, access_token: str, access_secret: str):
18
+ """
19
+ Initializes the Twitter client for a given character.
20
+
21
+ :param character_name: Name of the AI character.
22
+ :param api_key: Twitter API Key.
23
+ :param api_secret: Twitter API Secret Key.
24
+ :param access_token: Twitter Access Token.
25
+ :param access_secret: Twitter Access Token Secret.
26
+ """
27
+ self.character_name = character_name
28
+
29
+ # Authenticate with Twitter API
30
+ auth = tweepy.OAuthHandler(api_key, api_secret)
31
+ auth.set_access_token(access_token, access_secret)
32
+ self.api = tweepy.API(auth, wait_on_rate_limit=True)
33
+
34
+ # Schedule tweets
35
+ self.schedule_tweets()
36
+
37
+ def generate_tweet(self) -> str:
38
+ """
39
+ Generates a tweet using AI for the character.
40
+ This function can be modified to pull from AI-generated content.
41
+
42
+ :return: A string containing the tweet.
43
+ """
44
+ tweet_templates = [
45
+ f"{self.character_name} is thinking about the future of DeFi... 🚀",
46
+ f"GM! {self.character_name} says stay bullish today. 🌞",
47
+ f"On-chain or it didn't happen! - {self.character_name} ⛓️",
48
+ f"{self.character_name} is stacking sats and stacking wisdom. 💡",
49
+ f"Wen moon? {self.character_name} says HODL tight! 🌙"
50
+ ]
51
+ return random.choice(tweet_templates)
52
+
53
+ def post_tweet(self):
54
+ """
55
+ Posts a tweet for the character.
56
+ """
57
+ try:
58
+ tweet_content = self.generate_tweet()
59
+ self.api.update_status(tweet_content)
60
+ print(f"✅ {self.character_name} tweeted: {tweet_content}")
61
+ except Exception as e:
62
+ print(f"❌ Failed to post tweet for {self.character_name}: {e}")
63
+
64
+ def schedule_tweets(self):
65
+ """
66
+ Schedules tweets to be sent 5 times per 24-hour period.
67
+ Runs in a separate thread to avoid blocking the main agent process.
68
+ """
69
+ def tweet_scheduler():
70
+ while True:
71
+ for _ in range(5): # Post 5 tweets per day
72
+ self.post_tweet()
73
+ sleep_time = (24 * 60 * 60) // 5 # Spread tweets across 24 hours
74
+ print(f"⏳ Next tweet in {sleep_time // 60} minutes...")
75
+ time.sleep(sleep_time)
76
+
77
+ thread = Thread(target=tweet_scheduler, daemon=True)
78
+ thread.start()
@@ -0,0 +1,39 @@
1
+ from mezo_agent.config import web3_instance, query_graph
2
+ from mezo_agent.token_utils import get_token_address_by_symbol # ✅ Import from token_utils.py
3
+
4
+ def get_token_price(token_symbol: str) -> str:
5
+ """
6
+ Fetches the price of a given token in USD and ETH from the Goldsky subgraph.
7
+
8
+ :param token_symbol: The token symbol (e.g., 'MUSD', 'WBTC').
9
+ :return: A formatted string with the token price in USD and ETH.
10
+ """
11
+ if token_symbol.lower() == "btc":
12
+ token_symbol = "wtbtc"
13
+
14
+ try:
15
+ token_address = get_token_address_by_symbol(token_symbol) # ✅ Now correctly imported
16
+ except Exception as e:
17
+ return f"❌ Token lookup error: {e}"
18
+
19
+ token_id = token_address.lower()
20
+ query = f'''
21
+ {{
22
+ token(id: "{token_id}") {{
23
+ id
24
+ decimals
25
+ derivedUSD
26
+ derivedETH
27
+ }}
28
+ }}
29
+ '''
30
+ try:
31
+ result = query_graph(query)
32
+ token_data = result["data"]["token"]
33
+ if token_data is None:
34
+ return f"❌ Price data for token {token_symbol.upper()} not found."
35
+ derivedUSD = token_data.get("derivedUSD", "N/A")
36
+ derivedETH = token_data.get("derivedETH", "N/A")
37
+ return f"✅ Price of {token_symbol.upper()}: {derivedUSD} USD, {derivedETH} ETH."
38
+ except Exception as e:
39
+ return f"❌ Failed to get price data: {e}"
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="mezoAgent",
5
- version="0.6.4",
5
+ version="0.7.0",
6
6
  packages=find_packages(),
7
7
  include_package_data=True,
8
8
  package_data={
@@ -1,70 +0,0 @@
1
- from mezo_agent.config import web3_instance, query_graph
2
- from mezo_agent.utils import get_token_address_by_symbol
3
-
4
- def get_token_address_by_symbol(symbol: str) -> str:
5
- """
6
- Fetches the token contract address dynamically from the Goldsky subgraph.
7
- :param symbol: Token symbol (e.g., 'MUSD', 'WBTC').
8
- :return: Ethereum checksum address of the token.
9
- """
10
- if symbol.lower() == "btc":
11
- symbol = "wtbtc"
12
-
13
- query_all = '''
14
- {
15
- tokens(first: 100) {
16
- id
17
- symbol
18
- }
19
- }
20
- '''
21
- data = query_graph(query_all)
22
- tokens = data.get("data", {}).get("tokens", [])
23
- matching_tokens = [t for t in tokens if t["symbol"].lower() == symbol.lower()]
24
-
25
- if matching_tokens:
26
- token_address = matching_tokens[0]["id"]
27
- checksum_address = web3_instance.to_checksum_address(token_address)
28
- print(f"✅ Token {symbol} found at address: {checksum_address}") # Debugging
29
- return checksum_address
30
- else:
31
- available_symbols = [t["symbol"] for t in tokens]
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}"
File without changes
File without changes
File without changes
File without changes