mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
examples dir
This commit is contained in:
@@ -0,0 +1,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 send_hook(self, conversation: sm.Conversation):
|
||||
for m in self.yield_memories():
|
||||
conversation.add_message(role="system", text=m)
|
||||
|
||||
|
||||
conversation = sm.create_conversation(llm_model="grok-beta", llm_provider="xai")
|
||||
conversation.add_plugin(SimpleMemoryPlugin())
|
||||
|
||||
conversation.add_message(
|
||||
role="user",
|
||||
text="Write a poem about the moon",
|
||||
)
|
||||
|
||||
r = conversation.send()
|
||||
print(r.text)
|
||||
Reference in New Issue
Block a user