Fresh start - excluded large ROM JSON files

This commit is contained in:
OpenClaw Agent
2026-04-11 09:45:12 -05:00
commit 5deb387aa6
395 changed files with 47744 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
"""
Session Memory Snapshotter
==========================
Auto-summarizes conversation and embeds it.
Called every 15 messages.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from datetime import datetime
from memory_vector import store_memory
import requests
OLLAMA_URL = "http://localhost:11434"
EMBED_MODEL = "nomic-embed-text"
def get_embedding(text: str) -> list:
"""Generate embedding via Ollama."""
response = requests.post(
f"{OLLAMA_URL}/api/embeddings",
json={"model": EMBED_MODEL, "prompt": text[:2000]},
timeout=30
)
response.raise_for_status()
return response.json()["embedding"]
def save_snapshot(summary: str, participants: str = "Corey, Alex"):
"""Save a conversation snapshot with embedding."""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
# Generate embedding
embedding = get_embedding(summary)
# Store in database
source_path = f"session://{datetime.now().strftime('%Y-%m-%d')}#{timestamp}"
store_memory(
source_type="session_snapshot",
source_path=source_path,
content=summary,
embedding=embedding
)
return source_path
if __name__ == "__main__":
# Called with summary as argument
if len(sys.argv) < 2:
print("Usage: python session_snapshotter.py 'summary text'")
sys.exit(1)
summary = sys.argv[1]
path = save_snapshot(summary)
print(f"[OK] Snapshot saved: {path}")