File size: 1,960 Bytes
c413b9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test the RAG endpoint logic without starting the full API server
"""

from knowledge_extractor import extract_knowledge_for_aspects, get_aspect_summary

# Sample aspects data (same format as API returns)
test_aspects = [
    {"planet1": "Sun", "planet2": "Moon", "aspect": "trine", "orb": 2.5},
    {"planet1": "Venus", "planet2": "Mars", "aspect": "square", "orb": 3.1},
    {"planet1": "Moon", "planet2": "Mercury", "aspect": "conjunction", "orb": 1.2},
    {"planet1": "Sun", "planet2": "Jupiter", "aspect": "sextile", "orb": 4.0},
    {"planet1": "Mars", "planet2": "Saturn", "aspect": "opposition", "orb": 5.5}
]

print("=" * 70)
print("🔮 Testing RAG Endpoint Logic")
print("=" * 70)

# Test knowledge extraction
print(f"\n📊 Testing with {len(test_aspects)} aspects...")
knowledge_context = extract_knowledge_for_aspects(test_aspects)

# Test aspect summary
aspect_summary = get_aspect_summary(test_aspects, limit=5)

# Count knowledge found/missing
knowledge_found = knowledge_context.count("## ")
knowledge_missing = knowledge_context.count("*Knowledge base entry not yet available*")

# Display results (same as API endpoint would return)
result = {
    "knowledge_context": knowledge_context,
    "aspect_summary": aspect_summary,
    "aspects_count": len(test_aspects),
    "knowledge_found": knowledge_found,
    "knowledge_missing": knowledge_missing
}

print(f"\n✅ Results:")
print(f"   - Total aspects: {result['aspects_count']}")
print(f"   - Knowledge found: {result['knowledge_found']}")
print(f"   - Knowledge missing: {result['knowledge_missing']}")
print(f"   - Context length: {len(result['knowledge_context'])} characters")

print(f"\n📝 Aspect Summary:")
print(result['aspect_summary'])

print(f"\n📚 Knowledge Context Preview (first 800 chars):")
print("-" * 70)
print(result['knowledge_context'][:800] + "...")

print("\n" + "=" * 70)
print("✅ RAG endpoint logic test PASSED!")
print("=" * 70)