-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
38 lines (30 loc) · 1.29 KB
/
Copy pathdemo.py
File metadata and controls
38 lines (30 loc) · 1.29 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
from __future__ import annotations
from pathlib import Path
from tempfile import TemporaryDirectory
from app.engine import MemoryEngine
from app.evaluation import evaluate_memory_behavior
from app.schemas import ChatRequest
from app.storage import MemoryStore
def run_demo() -> None:
temp_dir = TemporaryDirectory(ignore_cleanup_errors=True)
store = MemoryStore(Path(temp_dir.name) / "demo_memory.db")
engine = MemoryEngine(store)
user_id = "demo"
prompts = [
"Remember that I prefer concise technical answers with implementation details.",
"My goal is to become an LLM Engineer focused on agents and RAG.",
"What do you remember about my AI career goal?",
"Forget my preference for concise technical answers.",
]
for prompt in prompts:
response = engine.chat(ChatRequest(user_id=user_id, message=prompt))
print(f"\nUser: {prompt}")
print(f"Agent: {response.answer}")
print(f"Trace: {response.trace}")
print("\nMemories:")
for memory in store.list_memories(user_id, include_deleted=True):
print(f"- {memory.status.value} | {memory.memory_type.value} | {memory.summary}")
print("\nEvaluation:")
print(evaluate_memory_behavior(store, user_id).model_dump())
if __name__ == "__main__":
run_demo()