-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_embeddings.py
More file actions
64 lines (55 loc) · 2.31 KB
/
Copy pathtest_embeddings.py
File metadata and controls
64 lines (55 loc) · 2.31 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
"""Quick test to verify ChromaDB embeddings work."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from bot.embeddings import EmbeddingManager
print("=" * 60)
print("Testing ChromaDB Embeddings")
print("=" * 60)
print()
em = EmbeddingManager()
print(f"✓ EmbeddingManager initialized")
print(f"✓ Collections exist: {em.collections_exist}")
print()
# Test the problematic column
print("Testing 'Sub Type Of The Surgery' collection...")
try:
# Test with very low threshold to see ALL matches
results = em.search("spine", columns=["Sub Type Of The Surgery"], top_k=10, threshold=0.0)
print(f"✓ Search successful! Found {len(results)} results (threshold=0.0, showing top 10):")
for i, r in enumerate(results[:10], 1):
print(f" {i}. {r['text'][:70]}... (similarity: {r['similarity']:.3f})")
# Test with default threshold
results_default = em.search("spine surgery", columns=["Sub Type Of The Surgery"], top_k=5)
print(f"\n With default threshold (0.7): {len(results_default)} results")
if results_default:
for r in results_default:
print(f" - {r['text'][:60]}... ({r['similarity']:.3f})")
except Exception as e:
print(f"✗ Error: {e}")
import traceback
traceback.print_exc()
print()
print("Testing 'Descriptio Of Surgery' for 'hernia'...")
try:
results = em.search("hernia", columns=["Descriptio Of Surgery"], top_k=10, threshold=0.0)
print(f"✓ Found {len(results)} results (threshold=0.0, showing top 5):")
for i, r in enumerate(results[:5], 1):
print(f" {i}. {r['text'][:70]}... (similarity: {r['similarity']:.3f})")
results_default = em.search("hernia", columns=["Descriptio Of Surgery"], top_k=5)
print(f"\n With default threshold (0.7): {len(results_default)} results")
except Exception as e:
print(f"✗ Error: {e}")
print()
print("Testing 'Reason of Admission' for 'hernia'...")
try:
results = em.search("hernia", columns=["Reason of Admission"], top_k=5, threshold=0.0)
print(f"✓ Found {len(results)} results (threshold=0.0, showing top 5):")
for i, r in enumerate(results[:5], 1):
print(f" {i}. {r['text'][:70]}... (similarity: {r['similarity']:.3f})")
except Exception as e:
print(f"✗ Error: {e}")
print()
print("=" * 60)
print("Test complete")
print("=" * 60)