-
Notifications
You must be signed in to change notification settings - Fork 0
Add mem-layer integration for persistent cross-agent memory #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,50 @@ | ||
| # 🌙 Moon Dev's Compliance Agent Requirements 🌙 | ||
| # Created with ❤️ by Moon Dev's AI Assistant | ||
|
|
||
| # Core dependencies | ||
| numpy>=1.24.0 | ||
| opencv-python>=4.8.0 | ||
| whisper>=1.1.10 | ||
| openai>=1.51.0 | ||
| anthropic>=0.5.0 | ||
| groq>=0.4.0 | ||
| # google-generativeai>=0.3.0 # Temporarily disabled due to protobuf conflict | ||
| # To re-enable Gemini, uncomment above and ensure compatible versions: | ||
| # google-generativeai==0.8.3 | ||
| # protobuf==4.25.1 | ||
| # proto-plus==1.25.0 | ||
| termcolor>=2.3.0 | ||
| python-dotenv>=1.0.0 | ||
| pathlib>=1.0.1 | ||
|
|
||
| # For transcription | ||
| openai-whisper>=20231117 | ||
| ffmpeg-python>=0.2.0 | ||
|
|
||
| # For image processing | ||
| pillow>=10.0.0 | ||
|
|
||
| # For API access | ||
| requests>=2.31.0 | ||
|
|
||
| # For data handling | ||
| pandas>=2.0.0 | ||
|
|
||
| # For progress bars and arXiv paper downloader | ||
| # Updated by Moon Dev's AI Assistant on arXiv downloader project | ||
| tqdm>=4.66.0 | ||
|
|
||
| backtesting>=0.3.3 | ||
| ta-lib>=0.4.0 | ||
| PyPDF2>=3.0.0 | ||
| youtube-transcript-api>=0.6.2 | ||
| pandas-ta>=0.3.14b0 | ||
|
|
||
| # MetaTrader 5 Integration | ||
| MetaTrader5>=5.0.45 | ||
|
|
||
| # Production Utilities | ||
| psutil>=5.9.0 # System monitoring | ||
| annotated-types==0.7.0 | ||
| argcomplete==3.1.4 | ||
| blinker==1.7.0 | ||
| certifi==2025.10.5 | ||
| charset-normalizer==3.4.4 | ||
| click==8.3.0 | ||
| click-default-group==1.2.4 | ||
| colorama==0.4.6 | ||
| conan==2.22.1 | ||
| cryptography==41.0.7 | ||
| dbus-python==1.3.2 | ||
| distro==1.8.0 | ||
| fasteners==0.20 | ||
| httplib2==0.20.4 | ||
| idna==3.11 | ||
| Jinja2==3.1.6 | ||
| launchpadlib==1.11.0 | ||
| lazr.restfulclient==0.14.6 | ||
| lazr.uri==1.0.6 | ||
| markdown-it-py==4.0.0 | ||
| MarkupSafe==3.0.3 | ||
| mdurl==0.1.2 | ||
| mem-layer @ git+https://github.com/icojerrel/mem-layer.git@d5573c9f7600b485c79051065bf66b8f76d6acb4 | ||
| networkx==3.5 | ||
| oauthlib==3.2.2 | ||
| packaging==24.0 | ||
| patch-ng==1.18.1 | ||
| pluggy==1.6.0 | ||
| pydantic==2.12.4 | ||
| pydantic_core==2.41.5 | ||
| Pygments==2.19.2 | ||
| PyGObject==3.48.2 | ||
| PyJWT==2.7.0 | ||
| pyparsing==3.1.1 | ||
| python-apt==2.7.7+ubuntu5 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove distro-only This version identifier is Ubuntu-specific; there is no matching wheel on PyPI, so 🤖 Prompt for AI Agents |
||
| python-dateutil==2.9.0.post0 | ||
| PyYAML==6.0.1 | ||
| requests==2.32.5 | ||
| rich==14.2.0 | ||
| six==1.16.0 | ||
| sqlite-fts4==1.0.3 | ||
| sqlite-utils==3.38 | ||
| tabulate==0.9.0 | ||
| toml==0.10.2 | ||
| typing-inspection==0.4.2 | ||
| typing_extensions==4.15.0 | ||
| urllib3==2.5.0 | ||
| wadllib==1.3.6 | ||
| xmltodict==0.13.0 | ||
| yq==3.1.0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,9 +91,17 @@ def patched_client(*args, **kwargs): | |
|
|
||
| httpx.Client = patched_client | ||
|
|
||
| # imports | ||
| # imports | ||
| from twikit import Client, TooManyRequests, BadRequest | ||
|
|
||
| # Memory integration | ||
| try: | ||
| from src.memory import AgentMemory, MemoryScope | ||
| MEMORY_AVAILABLE = True | ||
| except ImportError: | ||
| MEMORY_AVAILABLE = False | ||
| print("⚠️ Memory module not available - running without persistent memory") | ||
|
|
||
| class SentimentAgent: | ||
| def __init__(self): | ||
| """Initialize the Sentiment Agent""" | ||
|
|
@@ -102,15 +110,23 @@ def __init__(self): | |
| self.model = None | ||
| self.audio_dir = Path("src/audio") | ||
| self.audio_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Initialize sentiment history file | ||
| if not os.path.exists(SENTIMENT_HISTORY_FILE): | ||
| pd.DataFrame(columns=['timestamp', 'sentiment_score', 'num_tweets']).to_csv(SENTIMENT_HISTORY_FILE, index=False) | ||
|
|
||
| # Load the sentiment model at initialization | ||
| cprint("🤖 Loading sentiment model...", "cyan") | ||
| self.init_sentiment_model() | ||
|
|
||
|
|
||
| # Initialize memory | ||
| if MEMORY_AVAILABLE: | ||
| self.memory = AgentMemory(agent_name="sentiment_agent") | ||
| if self.memory.enabled: | ||
| cprint("🧠 Memory layer initialized", "cyan") | ||
| else: | ||
| self.memory = None | ||
|
|
||
| cprint("🌙 Moon Dev's Sentiment Agent initialized!", "green") | ||
|
|
||
| def init_sentiment_model(self): | ||
|
|
@@ -197,7 +213,7 @@ def save_sentiment_score(self, sentiment_score, num_tweets): | |
| 'sentiment_score': sentiment_score, | ||
| 'num_tweets': num_tweets | ||
| }]) | ||
|
|
||
| # Load existing data | ||
| if os.path.exists(SENTIMENT_HISTORY_FILE): | ||
| history_df = pd.read_csv(SENTIMENT_HISTORY_FILE) | ||
|
|
@@ -212,9 +228,33 @@ def save_sentiment_score(self, sentiment_score, num_tweets): | |
| history_df = pd.concat([history_df, new_data], ignore_index=True) | ||
| else: | ||
| history_df = new_data | ||
|
|
||
| history_df.to_csv(SENTIMENT_HISTORY_FILE, index=False) | ||
|
|
||
|
|
||
| # Store in memory layer | ||
| if self.memory and self.memory.enabled: | ||
| # Convert score to readable label | ||
| if sentiment_score > 0.3: | ||
| label = "very positive" | ||
| elif sentiment_score > 0: | ||
| label = "slightly positive" | ||
| elif sentiment_score > -0.3: | ||
| label = "slightly negative" | ||
| else: | ||
| label = "very negative" | ||
|
|
||
| self.memory.store( | ||
| f"Sentiment: {label} (score: {sentiment_score:.2f}) from {num_tweets} tweets", | ||
| scope=MemoryScope.SENTIMENT, | ||
| priority="medium", | ||
| metadata={ | ||
| "sentiment_score": sentiment_score, | ||
| "num_tweets": num_tweets, | ||
| "score_percent": (sentiment_score + 1) * 50, | ||
| "label": label | ||
| } | ||
| ) | ||
|
Comment on lines
+247
to
+256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure metadata uses JSON-serializable primitives
- self.memory.store(
+ self.memory.store(
f"Sentiment: {label} (score: {sentiment_score:.2f}) from {num_tweets} tweets",
scope=MemoryScope.SENTIMENT,
priority="medium",
metadata={
- "sentiment_score": sentiment_score,
- "num_tweets": num_tweets,
- "score_percent": (sentiment_score + 1) * 50,
+ "sentiment_score": float(sentiment_score),
+ "num_tweets": int(num_tweets),
+ "score_percent": float((sentiment_score + 1) * 50),
"label": label
}
)
@@
- self.memory.broadcast(
+ self.memory.broadcast(
f"EXTREME sentiment detected: {sentiment} ({score_percent:.1f}/100)",
scope=MemoryScope.ALERTS,
priority="high",
metadata={
- "sentiment_score": sentiment_score,
+ "sentiment_score": float(sentiment_score),
"label": sentiment,
- "num_tweets": len(texts)
+ "num_tweets": len(texts)
}
)
@@
- self.memory.broadcast(
+ self.memory.broadcast(
f"Large sentiment shift {direction}: {abs(percent_change):.1f} points in {int(time_diff)} min",
scope=MemoryScope.ALERTS,
priority="high",
metadata={
- "percent_change": percent_change,
- "time_minutes": int(time_diff),
- "current_score": sentiment_score
+ "percent_change": float(percent_change),
+ "time_minutes": int(time_diff),
+ "current_score": float(sentiment_score)
}
)Also applies to: 349-372 🤖 Prompt for AI Agents |
||
|
|
||
| except Exception as e: | ||
| cprint(f"❌ Error saving sentiment history: {str(e)}", "red") | ||
|
|
||
|
|
@@ -300,11 +340,37 @@ def analyze_and_announce_sentiment(self, tweets): | |
| message += f" - a small {abs(percent_change):.1f}% change" | ||
|
|
||
| message += "." | ||
|
|
||
| # Announce with voice if sentiment is significant or if there's a big change | ||
| is_important = abs(sentiment_score) > SENTIMENT_ANNOUNCE_THRESHOLD or (percent_change is not None and abs(percent_change) > 5) | ||
| self._announce(message, is_important) | ||
|
|
||
|
|
||
| # Broadcast extreme sentiment or significant changes to all agents | ||
| if self.memory and self.memory.enabled: | ||
| if abs(sentiment_score) > 0.5: # Very extreme sentiment | ||
| self.memory.broadcast( | ||
| f"EXTREME sentiment detected: {sentiment} ({score_percent:.1f}/100)", | ||
| scope=MemoryScope.ALERTS, | ||
| priority="high", | ||
| metadata={ | ||
| "sentiment_score": sentiment_score, | ||
| "label": sentiment, | ||
| "num_tweets": len(texts) | ||
| } | ||
| ) | ||
| elif percent_change is not None and abs(percent_change) > 10: # Big sentiment shift | ||
| direction = "up" if percent_change > 0 else "down" | ||
| self.memory.broadcast( | ||
| f"Large sentiment shift {direction}: {abs(percent_change):.1f} points in {int(time_diff)} min", | ||
| scope=MemoryScope.ALERTS, | ||
| priority="high", | ||
| metadata={ | ||
| "percent_change": percent_change, | ||
| "time_minutes": int(time_diff), | ||
| "current_score": sentiment_score | ||
| } | ||
| ) | ||
|
|
||
| # If not announcing vocally, print the raw score for debugging | ||
| if not is_important: | ||
| cprint(f"📊 Raw sentiment score: {sentiment_score:.2f} (on scale of -1 to 1)", "cyan") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade vulnerable
cryptographypincryptography==41.0.7is subject to multiple high-severity advisories (e.g., CVE-2023-50782, CVE-2024-26130). Please move to a patched release (>=42.0.0) before shipping to avoid known remote-attack and DoS vectors.(osv.dev)🧰 Tools
🪛 OSV Scanner (2.2.4)
[HIGH] 10-10: cryptography 41.0.7: undefined
(PYSEC-2024-225)
[HIGH] 10-10: cryptography 41.0.7: Python Cryptography package vulnerable to Bleichenbacher timing oracle attack
(GHSA-3ww4-gg4f-jr7f)
[HIGH] 10-10: cryptography 41.0.7: cryptography NULL pointer dereference with pkcs12.serialize_key_and_certificates when called with a non-matching certificate and private key and an hmac_hash override
(GHSA-6vqw-3v5j-54x4)
[HIGH] 10-10: cryptography 41.0.7: Null pointer dereference in PKCS12 parsing
(GHSA-9v9h-cgj8-h64p)
[HIGH] 10-10: cryptography 41.0.7: pyca/cryptography has a vulnerable OpenSSL included in cryptography wheels
(GHSA-h4gh-qq45-vh27)
🤖 Prompt for AI Agents