forked from vektori-ai/vektori
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.py
More file actions
56 lines (43 loc) · 1.42 KB
/
Copy pathquickstart.py
File metadata and controls
56 lines (43 loc) · 1.42 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Vektori Quickstart — SQLite, zero config.
No Docker. No API keys (uses Ollama locally).
Prerequisites:
pip install vektori
ollama pull nomic-embed-text
ollama pull llama3
"""
import asyncio
from vektori import Vektori
async def main():
# SQLite default at ~/.vektori/vektori.db
v = Vektori(
embedding_model="ollama:nomic-embed-text",
extraction_model="ollama:llama3",
)
print("Adding memories...")
result = await v.add(
messages=[
{"role": "user", "content": "I only use WhatsApp, please don't email me."},
{"role": "assistant", "content": "Understood, WhatsApp only."},
{"role": "user", "content": "My outstanding amount is ₹45,000 and I can pay by Friday."},
],
session_id="call-001",
user_id="user-123",
)
print(f"Stored: {result}")
await asyncio.sleep(5) # wait for async fact extraction
print("\nSearching (L1 — facts + episodes)...")
results = await v.search(
query="How does this user prefer to communicate?",
user_id="user-123",
depth="l1",
)
print("\nFacts:")
for fact in results.get("facts", []):
print(f" [{fact.get('score', 0):.3f}] {fact['text']}")
print("\nEpisodes:")
for episode in results.get("episodes", []):
print(f" {episode['text']}")
await v.close()
if __name__ == "__main__":
asyncio.run(main())