-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview_memory.py
More file actions
59 lines (45 loc) · 1.9 KB
/
view_memory.py
File metadata and controls
59 lines (45 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Memory Database Viewer
View all stored conversations without resetting.
"""
import chromadb
from datetime import datetime
from config.config import MEMORY_DIR, MEMORY_COLLECTION
def view_memory():
"""Display all stored conversations."""
print("=" * 80)
print("Memory Database Viewer")
print("=" * 80)
try:
client = chromadb.PersistentClient(path=str(MEMORY_DIR))
collection = client.get_collection(name=MEMORY_COLLECTION)
count = collection.count()
print(f"\nTotal conversations stored: {count}")
if count == 0:
print("\nNo conversations found. The memory is empty.")
return
# Get all entries
results = collection.get(
include=["metadatas", "documents"]
)
print("\n" + "=" * 80)
print("Stored Conversations")
print("=" * 80)
for i, (doc_id, metadata, document) in enumerate(
zip(results["ids"], results["metadatas"], results["documents"]), 1
):
timestamp = metadata.get("timestamp", 0)
dt = datetime.fromtimestamp(timestamp)
user_msg = metadata.get("user_message", "")
assistant_msg = metadata.get("assistant_response", "")
sentiment = metadata.get("sentiment_label", "unknown")
emotion = metadata.get("emotion", "unknown")
print(f"\n[{i}] {dt.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Sentiment: {sentiment} | Emotion: {emotion}")
print(f" User: {user_msg[:100]}{'...' if len(user_msg) > 100 else ''}")
print(f" AI: {assistant_msg[:100]}{'...' if len(assistant_msg) > 100 else ''}")
print("\n" + "=" * 80)
except Exception as e:
print(f"\n✗ Error reading memory: {e}")
if __name__ == "__main__":
view_memory()