-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsimple_memory.py
More file actions
28 lines (20 loc) · 706 Bytes
/
Copy pathsimple_memory.py
File metadata and controls
28 lines (20 loc) · 706 Bytes
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
from _context import sm
class SimpleMemoryPlugin:
def __init__(self):
self.memories = [
"the earth has fictionally beeen destroyed.",
"the moon is made of cheese.",
]
def yield_memories(self):
return (m for m in self.memories)
def initialize_hook(self, conversation: sm.Conversation):
for m in self.yield_memories():
conversation.prepend_system_message(text=m)
conversation = sm.create_conversation(llm_model="grok-beta", llm_provider="xai")
conversation.add_plugin(SimpleMemoryPlugin())
conversation.add_message(
role="user",
text="Please write a poem about the moon",
)
r = conversation.send()
print(r.text)