-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_packer_search.py
More file actions
executable file
·97 lines (80 loc) · 2.63 KB
/
test_packer_search.py
File metadata and controls
executable file
·97 lines (80 loc) · 2.63 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
91
92
93
94
95
96
97
#!/usr/bin/env python3
"""
Test client for Cognee API - Search only test for packer priming
Assumes packer.md has already been added and cognified
"""
import asyncio
import sys
from client import CogneeClient, SearchType
async def main():
# Configuration
COGNEE_URL = "http://eva_cognee:8181"
DATASET_NAME = "DesconSim"
print("=" * 80)
print("Cognee API Test - Search Packer Priming and Downstream Control")
print("=" * 80)
print()
# Initialize Cognee client
print(f"Connecting to Cognee API at {COGNEE_URL}...")
client = CogneeClient(base_url=COGNEE_URL, timeout=300.0)
print("✓ Client initialized")
print()
try:
# Health check
print("Checking server health...")
health_result = await client.health()
print(f"✓ Server is healthy: {health_result}")
print()
# Search for packer priming and downstream control
print("=" * 80)
print("SEARCH: 'Explain packer priming and downstream control'")
print("=" * 80)
print()
search_result = await client.search(
query_text="Explain packer priming and downstream control",
query_type=SearchType.GRAPH_COMPLETION
)
if search_result.get("success"):
print("✓ Search completed successfully")
print()
print("-" * 80)
print("RESULTS:")
print("-" * 80)
print()
# Display the search results
search_data = search_result.get("data", [])
if isinstance(search_data, list):
if len(search_data) == 0:
print("No results returned")
else:
for i, item in enumerate(search_data, 1):
print(f"Result {i}:")
print(item)
print()
elif isinstance(search_data, dict):
for key, value in search_data.items():
print(f"{key}:")
print(f" {value}")
print()
else:
print(search_data)
print("-" * 80)
else:
print(f"ERROR: Search failed: {search_result}")
return 1
except Exception as e:
print(f"ERROR: Operation failed: {e}")
import traceback
traceback.print_exc()
return 1
finally:
# Cleanup
await client.close()
print()
print("✓ Client connection closed")
print()
print("Search test completed!")
return 0
if __name__ == "__main__":
exit_code = asyncio.run(main())
sys.exit(exit_code)