adding total memory counter bottom of Memory_Manager output
Browse files
app.py
CHANGED
|
@@ -888,6 +888,9 @@ def _mem_list(
|
|
| 888 |
if include_tags and m.get("tags"):
|
| 889 |
base += f" | tags: {m['tags']}"
|
| 890 |
lines.append(base)
|
|
|
|
|
|
|
|
|
|
| 891 |
return "\n".join(lines)
|
| 892 |
|
| 893 |
|
|
@@ -919,16 +922,23 @@ def _mem_search(
|
|
| 919 |
with _MEMORY_LOCK:
|
| 920 |
memories = _load_memories()
|
| 921 |
# Newest first iteration for early cutoff
|
| 922 |
-
matches: List[Dict[str, str]] = []
|
|
|
|
| 923 |
for m in reversed(memories): # newest backward
|
| 924 |
hay = (m.get("text", "") + " " + m.get("tags", "")).lower()
|
| 925 |
if all(t in hay for t in terms):
|
| 926 |
-
|
| 927 |
-
if len(matches)
|
| 928 |
-
|
| 929 |
if not matches:
|
| 930 |
return f"No matches for: {query}"
|
| 931 |
-
lines = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 932 |
return "\n".join(lines)
|
| 933 |
|
| 934 |
|
|
|
|
| 888 |
if include_tags and m.get("tags"):
|
| 889 |
base += f" | tags: {m['tags']}"
|
| 890 |
lines.append(base)
|
| 891 |
+
omitted = len(memories) - len(chosen)
|
| 892 |
+
if omitted > 0:
|
| 893 |
+
lines.append(f"… ({omitted} older memorie{'s' if omitted!=1 else ''} omitted; total={len(memories)})")
|
| 894 |
return "\n".join(lines)
|
| 895 |
|
| 896 |
|
|
|
|
| 922 |
with _MEMORY_LOCK:
|
| 923 |
memories = _load_memories()
|
| 924 |
# Newest first iteration for early cutoff
|
| 925 |
+
matches: List[Dict[str, str]] = [] # collected (capped at limit)
|
| 926 |
+
total_matches = 0
|
| 927 |
for m in reversed(memories): # newest backward
|
| 928 |
hay = (m.get("text", "") + " " + m.get("tags", "")).lower()
|
| 929 |
if all(t in hay for t in terms):
|
| 930 |
+
total_matches += 1
|
| 931 |
+
if len(matches) < limit:
|
| 932 |
+
matches.append(m)
|
| 933 |
if not matches:
|
| 934 |
return f"No matches for: {query}"
|
| 935 |
+
lines = [
|
| 936 |
+
f"{m['id'][:8]} [{m.get('timestamp','?')}] {m.get('text','')}" + (f" | tags: {m['tags']}" if m.get('tags') else "")
|
| 937 |
+
for m in matches
|
| 938 |
+
]
|
| 939 |
+
omitted = total_matches - len(matches)
|
| 940 |
+
if omitted > 0:
|
| 941 |
+
lines.append(f"… ({omitted} additional match{'es' if omitted!=1 else ''} omitted; total_matches={total_matches})")
|
| 942 |
return "\n".join(lines)
|
| 943 |
|
| 944 |
|