MCPcopy Index your code
hub / github.com/CaviraOSS/OpenMemory / advanced_example

Function advanced_example

examples/py-sdk/advanced_features.py:9–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7from openmemory import OpenMemory
8
9def advanced_example():
10 print('🧠 OpenMemory Python SDK - Advanced Features')
11 print('============================================')
12
13 # Initialize with advanced configuration
14 mem = OpenMemory(
15 path='./data/advanced-demo.sqlite',
16 tier='smart', # 'fast' | 'smart' | 'deep' | 'hybrid'
17 embeddings={
18 'provider': 'synthetic',
19 'mode': 'advanced',
20 'dimensions': 768
21 },
22 decay={
23 'intervalMinutes': 5,
24 'reinforceOnQuery': True,
25 'coldThreshold': 0.1
26 },
27 compression={
28 'enabled': True,
29 'algorithm': 'semantic',
30 'minLength': 100
31 },
32 reflection={
33 'enabled': True,
34 'intervalMinutes': 10,
35 'minMemories': 5
36 }
37 )
38
39 print('✅ OpenMemory initialized with advanced features')
40
41 # Multi-sector memories
42 print('\n1. Adding multi-sector memories...')
43
44 mem.add("Yesterday I learned how to implement binary search trees while feeling slightly frustrated",
45 tags=["learning", "coding", "emotion"],
46 metadata={"difficulty": "medium", "mood": "frustrated"})
47
48 mem.add("The capital of France is Paris, located on the Seine river",
49 tags=["geography", "facts"],
50 metadata={"type": "factual"})
51
52 mem.add("To make coffee: 1) Heat water to 200°F, 2) Add 2 tbsp grounds, 3) Pour slowly",
53 tags=["coffee", "procedure"],
54 metadata={"category": "cooking"})
55
56 mem.add("I'm thinking about why certain algorithms are more efficient than others",
57 tags=["reflection", "metacognition"],
58 metadata={"type": "reflective"})
59
60 print('✅ Added 4 memories across different sectors')
61
62 # Cross-sector query
63 print('\n2. Cross-sector query...')
64 results = mem.query("learning and emotions", limit=3)
65 print(f"✅ Found {len(results)} cross-sector matches")
66 for i, r in enumerate(results):

Callers 1

Calls 5

addMethod · 0.95
queryMethod · 0.95
getAllMethod · 0.95
closeMethod · 0.95
OpenMemoryClass · 0.90

Tested by

no test coverage detected