Spaces:
Sleeping
Sleeping
File size: 2,744 Bytes
2929135 |
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 |
# test_healthcare_agent_basic.py
import os
from datetime import datetime
from src.agent import HealthcareAgent
from src.models.state import TaskType, PriorityLevel
from src.utils.error_handlers import ValidationError, HealthcareError
def main():
"""Basic test of the Healthcare Operations Management Agent"""
try:
# 1. Test Agent Initialization
print("\n=== Testing Agent Initialization ===")
agent = HealthcareAgent(os.getenv("OPENAI_API_KEY"))
print("β Agent initialized successfully")
# 2. Test Basic Query - Patient Flow
print("\n=== Testing Patient Flow Query ===")
patient_query = "What is the current ER occupancy and wait time?"
response = agent.process(
input_text=patient_query,
thread_id="test-thread-1"
)
print(f"Query: {patient_query}")
print(f"Response: {response.get('response', 'No response')}")
print(f"Analysis: {response.get('analysis', {})}")
# 3. Test Resource Management Query
print("\n=== Testing Resource Management Query ===")
resource_query = "Check the current availability of ventilators and ICU beds"
response = agent.process(
input_text=resource_query,
thread_id="test-thread-1"
)
print(f"Query: {resource_query}")
print(f"Response: {response.get('response', 'No response')}")
print(f"Analysis: {response.get('analysis', {})}")
# 4. Test Conversation History
print("\n=== Testing Conversation History ===")
history = agent.get_conversation_history("test-thread-1")
print(f"Conversation history length: {len(history)}")
# 5. Test Reset Conversation
print("\n=== Testing Conversation Reset ===")
reset_success = agent.reset_conversation("test-thread-1")
print(f"Reset successful: {reset_success}")
# 6. Test Error Handling
print("\n=== Testing Error Handling ===")
try:
agent.process("")
print("β Error handling test failed - empty input accepted")
except ValidationError as ve:
print(f"β Error handling working correctly: Empty input rejected with validation error")
except HealthcareError as he:
print(f"β Error handling working correctly: {str(he)}")
except Exception as e:
print(f"β Unexpected error type: {type(e).__name__}: {str(e)}")
except Exception as e:
print(f"\nβ Test failed with error: {str(e)}")
if __name__ == "__main__":
print("Starting Healthcare Agent Basic Tests...")
print(f"Test Time: {datetime.now()}")
main() |