Repository navigation
Expand file tree
/
Copy pathzep_example.py
More file actions
80 lines (61 loc) · 2.66 KB
/
Copy pathzep_example.py
File metadata and controls
80 lines (61 loc) · 2.66 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
"""
Zep Example: Testing Zep Memory Tool
This example demonstrates how to use the Zep memory tool with LLMemoryMeter.
Shows store, retrieve, and chat operations using Zep's long-term memory capabilities.
Usage:
1. Copy .env.example to .env
2. Add your ZEP_API_KEY
3. Run: python zep_example.py
"""
import asyncio
from llmemory_meter import MemoryComparator
async def main():
print("🧠 LLMemoryMeter - Zep Memory Tool Example")
print("=" * 50)
# Initialize comparator
comparator = MemoryComparator()
# Create a simple test workload
workload = comparator.create_simple_workload(
name="Zep Memory Test",
memory_content="I am a data scientist who loves machine learning and works on NLP projects. I prefer Python and PyTorch.",
retrieval_query="What are my professional interests and preferred tools?"
)
print(f"📝 Testing workload: {workload.name}")
print(f" Memory content: {workload.steps[0].content}")
print(f" Query: {workload.steps[1].content}")
# Test Zep tool specifically
tools = ["zep"]
try:
print(f"\n🚀 Testing Zep memory tool...")
# Run comparison
results = await comparator.compare_tools(workload, tools)
# Print results
print(f"\n📊 Zep Results:")
print("-" * 40)
for tool_name, result in results.items():
print(f"\n🔧 {tool_name.upper()}:")
print(f" ✅ Success Rate: {result.success_rate*100:.0f}%")
print(f" ⚡ Total Time: {result.total_latency_ms:.0f}ms")
# Show step results
for i, step_result in enumerate(result.step_results):
action = step_result.action.upper()
status = "✅" if step_result.success else "❌"
print(f" {status} Step {i+1} ({action}): {step_result.latency_ms:.0f}ms")
print(f" Response: {step_result.response[:100]}...")
if not step_result.success:
print(f" Error: {step_result.error_message}")
print(f"\n🎯 Zep Features Demonstrated:")
print(" • Long-term memory storage")
print(" • Context-aware retrieval")
print(" • Session-based memory management")
print(" • Temporal knowledge graphs")
except Exception as e:
print(f"❌ Error: {e}")
print("\n💡 Make sure to:")
print(" 1. Copy .env.example to .env")
print(" 2. Add your ZEP_API_KEY")
print(" 3. Install dependencies: pip install -r requirements.txt")
print(" 4. Check Zep service availability")
if __name__ == "__main__":
asyncio.run(main())