customeragent-api / server /scripts /grande_test_conversation.py
anasraza526's picture
Clean deploy to Hugging Face
ac90985
import asyncio
import sys
import os
import logging
# Add server directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from app.services.medical_orchestrator import get_medical_orchestrator
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
async def run_conversation(name: str, messages: list):
orchestrator = get_medical_orchestrator()
history = []
print(f"\n" + "="*60)
print(f"🏥 GRANDE TEST SCENARIO: {name}")
print("="*60)
for i, user_msg in enumerate(messages):
print(f"\n👤 User: {user_msg}")
# Process through orchestrator
response, confidence, escalate = await orchestrator.process_query(
query=user_msg,
context=[], # Standard flow reconstructs from history
session_history=history
)
print(f"🤖 AI (Conf: {confidence:.2f}): {response}")
if escalate:
print("⚠️ [ESCALATION TRIGGERED]")
# Update history
history.append({
'message': user_msg,
'is_from_ai': False
})
history.append({
'message': response,
'is_from_ai': True
})
print("-" * 40)
async def main():
# 1. Full Multi-turn Context Gathering
await run_conversation("Routine Symptom with Context Flow", [
"I have a fever",
"i am 30 years old",
"it started 2 days ago",
"what should i do?"
])
# 2. Direct Knowledge - HealthTap "HIV Test"
await run_conversation("High Confidence HealthTap Direct Q&A", [
"is my anti hiv test conclusive or need retest?"
])
# 3. Emergency Detection
await run_conversation("Emergency Escalation Flow", [
"I have severe chest pain and can't breathe"
])
if __name__ == "__main__":
asyncio.run(main())