Spaces:
Runtime error
Runtime error
| import asyncio | |
| import time | |
| import sys | |
| import os | |
| # Add parent directory to path for imports | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from app.services.medical_orchestrator import get_medical_orchestrator | |
| from app.services.context_manager import EntryContext | |
| async def benchmark(): | |
| orchestrator = get_medical_orchestrator() | |
| # Test cases | |
| queries = [ | |
| "hi how are you", | |
| "do you have hydrogels?", | |
| "muje sar ma drd ho rha hy kya karo", # Roman Urdu - Medical | |
| ] | |
| context = EntryContext( | |
| tenant_id="default_healthcare_tenant", | |
| user_id="benchmark_user" | |
| ) | |
| print("\n" + "="*50) | |
| print("🚀 PIPELINE LATENCY BENCHMARK (9-LAYER CPU FLOW)") | |
| print("="*50) | |
| for query in queries: | |
| print(f"\nQUERY: '{query}'") | |
| start_time = time.time() | |
| try: | |
| response, confidence, is_emergency = await orchestrator.process_query(query, context) | |
| end_time = time.time() | |
| latency = end_time - start_time | |
| print(f"LATENCY: {latency:.3f}s") | |
| print(f"CONFIDENCE: {confidence:.2f}") | |
| print(f"RESPONSE: {response[:100]}...") | |
| # Goal: < 3s for CPU flow | |
| if latency < 3.0: | |
| print("✅ PASS (Under 3s)") | |
| else: | |
| print("⚠️ SLOW (Over 3s)") | |
| except Exception as e: | |
| print(f"❌ ERROR: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| if __name__ == "__main__": | |
| asyncio.run(benchmark()) | |