Update memory_manager.py
This commit is contained in:
1 parent
57984edc9a
commit
069df9f4b7
1 file changed
+1
-26
@@ -1,10 +1,3 @@
|
||||
"""
|
||||
memory_manager.py — JARVIS Long-Term Memory
|
||||
============================================
|
||||
Memory yalnızca Gemini Live'ın save_memory tool call'ı aracılığıyla güncellenir.
|
||||
Ayrı bir Gemini API çağrısı yapılmaz → sıfır 429 hatası.
|
||||
"""
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from threading import Lock
|
||||
@@ -24,9 +17,6 @@ _lock = Lock()
|
||||
MAX_VALUE_LENGTH = 380
|
||||
MEMORY_MAX_CHARS = 2200
|
||||
|
||||
|
||||
# ── Şema ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
def _empty_memory() -> dict:
|
||||
return {
|
||||
"identity": {},
|
||||
@@ -37,9 +27,6 @@ def _empty_memory() -> dict:
|
||||
"notes": {},
|
||||
}
|
||||
|
||||
|
||||
# ── Yükleme ───────────────────────────────────────────────────────────────────
|
||||
|
||||
def load_memory() -> dict:
|
||||
if not MEMORY_PATH.exists():
|
||||
return _empty_memory()
|
||||
@@ -57,9 +44,6 @@ def load_memory() -> dict:
|
||||
print(f"[Memory] ⚠️ Load error: {e}")
|
||||
return _empty_memory()
|
||||
|
||||
|
||||
# ── Boyut sınırı ──────────────────────────────────────────────────────────────
|
||||
|
||||
def _all_entries(memory: dict) -> list[tuple]:
|
||||
entries = []
|
||||
for cat, items in memory.items():
|
||||
@@ -83,9 +67,6 @@ def _trim_to_limit(memory: dict) -> dict:
|
||||
print(f"[Memory] 🗑️ Trimmed {cat}/{key}")
|
||||
return memory
|
||||
|
||||
|
||||
# ── Kaydetme ──────────────────────────────────────────────────────────────────
|
||||
|
||||
def save_memory(memory: dict) -> None:
|
||||
if not isinstance(memory, dict):
|
||||
return
|
||||
@@ -136,9 +117,6 @@ def update_memory(memory_update: dict) -> dict:
|
||||
print(f"[Memory] 💾 Saved: {list(memory_update.keys())}")
|
||||
return memory
|
||||
|
||||
|
||||
# ── Prompt formatı ────────────────────────────────────────────────────────────
|
||||
|
||||
def format_memory_for_prompt(memory: dict | None) -> str:
|
||||
if not memory:
|
||||
return ""
|
||||
@@ -215,9 +193,6 @@ def format_memory_for_prompt(memory: dict | None) -> str:
|
||||
|
||||
return result + "\n"
|
||||
|
||||
|
||||
# ── Yardımcı fonksiyonlar ─────────────────────────────────────────────────────
|
||||
|
||||
def remember(key: str, value: str, category: str = "notes") -> str:
|
||||
valid = {"identity", "preferences", "projects", "relationships", "wishes", "notes"}
|
||||
if category not in valid:
|
||||
@@ -237,4 +212,4 @@ def forget(key: str, category: str = "notes") -> str:
|
||||
return f"Not found: {category}/{key}"
|
||||
|
||||
|
||||
forget_memory = forget
|
||||
forget_memory = forget
|
||||
Reference in new issue
Block a user