-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_live.py
More file actions
68 lines (58 loc) · 2.17 KB
/
Copy pathtest_live.py
File metadata and controls
68 lines (58 loc) · 2.17 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
"""
Live end-to-end test: runs all 5 assessment sample queries through the
complete 5-stage Text-to-SQL pipeline with real LLM calls.
"""
import sys, os, time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
print("=" * 60)
print(" DOTMappers Live LLM Pipeline Test")
print("=" * 60)
# Init DB
from app.database import initialise_database
rows = initialise_database()
print(f"\n✅ SQLite loaded: {rows} tickets\n")
# Show cascade providers
from app.llm.factory import get_cascade
cascade = get_cascade()
print(f"✅ LLM Cascade: {' → '.join(cascade.all_providers)}")
print(f" Active provider: {cascade.active_provider}\n")
# Run all 5 assessment queries
from app.engines.query_engine import run_nl_query
queries = [
"How many tickets are currently open?",
"Which agent resolved the most tickets this month?",
"Show me all Critical tickets not resolved within 12 hours.",
"What is the average customer rating for Technical category tickets?",
"Are there any anomalies in resolution times this week?",
]
print("=" * 60)
print(" ASSESSMENT QUERY RESULTS")
print("=" * 60)
all_passed = True
for i, q in enumerate(queries, 1):
print(f"\n[Q{i}] {q}")
t0 = time.time()
result = run_nl_query(q)
elapsed = round((time.time() - t0) * 1000, 0)
if result.get("error") and not result.get("sql"):
print(f" ❌ FAILED: {result['error']}")
all_passed = False
else:
print(f" SQL : {result['sql'][:80]}{'...' if len(result.get('sql',''))>80 else ''}")
print(f" Rows : {result['row_count']}")
print(f" Answer : {result['answer'][:120]}")
print(f" Provider : {result['provider']} | Latency: {result['latency_ms']}ms | Cached: {result['cached']}")
print("\n" + "=" * 60)
print(" ANOMALY ENGINE TEST")
print("=" * 60)
from app.engines.anomaly_engine import detect_anomalies
anom = detect_anomalies()
print(f"\n Total anomalies : {anom['total_count']}")
print(f" By severity : {anom['counts_by_severity']}")
print(f" Summary : {anom['summary'][:100]}")
print("\n" + "=" * 60)
if all_passed:
print(" ALL LIVE TESTS PASSED ✅")
else:
print(" SOME TESTS FAILED ❌")
print("=" * 60)