-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathepisodic_memory.py
54 lines (44 loc) · 1.14 KB
/
episodic_memory.py
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
from memobase import MemoBaseClient, ChatBlob
PROJECT_URL = "http://localhost:8019"
PROJECT_TOKEN = "secret"
client = MemoBaseClient(
project_url=PROJECT_URL,
api_key=PROJECT_TOKEN,
)
assert client.ping(), "Your Memobase server is not running"
uid = client.add_user()
u = client.get_user(uid)
print("User ID is", uid)
print("Start processing...")
messages1 = [
{
"role": "user",
"content": "Hello, I'm Gus",
"created_at": "2025-01-14",
},
{
"role": "assistant",
"content": "Hi, nice to meet you, Gus!",
"alias": "HerAI",
},
]
blob = ChatBlob(messages=messages1)
bid = u.insert(blob)
u.flush()
messages2 = [
{
"role": "user",
"content": "My name is Tom now.",
},
]
blob = ChatBlob(messages=messages2)
bid = u.insert(blob)
u.flush()
events = u.event()
print("Below is recent memories:")
for e in events:
print("-----------------")
print("📅", e.created_at.astimezone().strftime("%Y-%m-%d %H:%M:%S"))
for i in e.event_data.profile_delta:
print("-", i.attributes["topic"], i.attributes["sub_topic"], i.content)
print("-----------------")