-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcognee_admin.py
More file actions
executable file
·90 lines (73 loc) · 2.78 KB
/
cognee_admin.py
File metadata and controls
executable file
·90 lines (73 loc) · 2.78 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
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
"""
Cognee Administration Utility
Manage Cognee memory, datasets, and system data
"""
import asyncio
import sys
from client import CogneeClient
async def main():
COGNEE_URL = "http://eva_cognee:8181"
if len(sys.argv) < 2:
print("Cognee Administration Utility")
print()
print("Usage: ./cognee_admin.py <command>")
print()
print("Commands:")
print(" health - Check server health")
print(" prune - Clear all data (documents, knowledge graphs)")
print(" prune_system - Clear system data (graph, vector, metadata, cache)")
print(" reset_all - Clear both data and system (complete reset)")
print()
return 1
command = sys.argv[1].lower()
client = CogneeClient(base_url=COGNEE_URL, timeout=300.0)
try:
if command == "health":
print("Checking server health...")
result = await client.health()
print(f"✓ {result}")
elif command == "prune":
print("Clearing all data (documents, knowledge graphs)...")
print("This will remove all datasets, documents, and processed data.")
confirm = input("Are you sure? (yes/no): ")
if confirm.lower() == "yes":
result = await client.prune()
print(f"✓ {result.get('message')}")
else:
print("Cancelled")
elif command == "prune_system":
print("Clearing system data (graph, vector, metadata, cache)...")
confirm = input("Are you sure? (yes/no): ")
if confirm.lower() == "yes":
result = await client.prune_system()
print(f"✓ {result.get('message')}")
else:
print("Cancelled")
elif command == "reset_all":
print("COMPLETE RESET - This will clear ALL data and system data!")
confirm = input("Are you absolutely sure? (yes/no): ")
if confirm.lower() == "yes":
print("\n1. Clearing data...")
result1 = await client.prune()
print(f" ✓ {result1.get('message')}")
print("2. Clearing system...")
result2 = await client.prune_system()
print(f" ✓ {result2.get('message')}")
print("\n✓ Complete reset finished!")
else:
print("Cancelled")
else:
print(f"ERROR: Unknown command '{command}'")
return 1
except Exception as e:
print(f"ERROR: {e}")
import traceback
traceback.print_exc()
return 1
finally:
await client.close()
return 0
if __name__ == "__main__":
exit_code = asyncio.run(main())
sys.exit(exit_code)