Spaces:
Running
Running
File size: 3,885 Bytes
24f95f0 | 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | """
Test script for switchboard routing enhancements.
"""
from app.agents.switchboard import decide_route
from app.domain_packs.init_packs import init_domain_packs
def test_routing():
"""Test the enhanced switchboard routing."""
# Initialize domain packs
init_domain_packs()
# Test cases
test_cases = [
# Simple queries (≤5 words)
{
"input": "Hello world",
"expected": {
"complexity": "simple",
"execution_mode": "solo",
"task_family": "normal",
"domain_pack": "general"
}
},
{
"input": "What is AAPL?",
"expected": {
"complexity": "simple",
"execution_mode": "solo",
"task_family": "normal",
"domain_pack": "general" # AAPL alone doesn't trigger finance keywords
}
},
# Medium queries (≤25 words)
{
"input": "Can you tell me about the latest stock market trends and what's happening with tech stocks?",
"expected": {
"complexity": "medium",
"execution_mode": "standard",
"task_family": "normal",
"domain_pack": "finance"
}
},
{
"input": "What are the best practices for software development in modern teams?",
"expected": {
"complexity": "medium",
"execution_mode": "standard",
"task_family": "normal",
"domain_pack": "general"
}
},
# Complex queries (>25 words)
{
"input": "I need a comprehensive analysis of the current market conditions including economic indicators, sector performance, and potential risks that could impact my investment portfolio over the next quarter.",
"expected": {
"complexity": "complex",
"execution_mode": "deep",
"task_family": "normal",
"domain_pack": "finance"
}
},
# Simulation queries
{
"input": "Simulate the market reaction to a Fed rate hike",
"expected": {
"complexity": "complex",
"execution_mode": "deep",
"task_family": "simulation",
"domain_pack": "finance"
}
},
{
"input": "What if the company announces bankruptcy?",
"expected": {
"complexity": "complex",
"execution_mode": "deep",
"task_family": "simulation",
"domain_pack": "finance" # "bankruptcy" is a finance keyword
}
},
]
print("Testing Switchboard Routing\n" + "="*50)
passed = 0
failed = 0
for i, test in enumerate(test_cases, 1):
user_input = test["input"]
expected = test["expected"]
result = decide_route(user_input)
print(f"\nTest {i}:")
print(f" Input: {user_input}")
print(f" Result: {result}")
# Check each expected field
test_passed = True
for key, expected_value in expected.items():
if result.get(key) != expected_value:
print(f" ❌ FAILED: {key} = {result.get(key)}, expected {expected_value}")
test_passed = False
if test_passed:
print(f" ✅ PASSED")
passed += 1
else:
failed += 1
print(f"\n{'='*50}")
print(f"Results: {passed} passed, {failed} failed out of {len(test_cases)} tests")
return failed == 0
if __name__ == "__main__":
success = test_routing()
exit(0 if success else 1)
|