| |
| import asyncio |
| from orchestrator import orchestrator, PipelineContext |
|
|
| async def run_tests(): |
| print("🚀 starting BuddyMath V4.2.16 Regression Test Matrix...\n") |
|
|
| test_cases = [ |
| { |
| "id": "CASE_1_SMADAR_ALGEBRA", |
| "name": "סמדר והמחברות (כיתה ז')", |
| "grade": "ז'", |
| "category": "ALGEBRA", |
| "math_input": "4x + 5y = 120, y = x + 6", |
| "text": "סמדר קנתה מחברות חשבון ב-4 שקלים וחלקות ב-5 שקלים. כמה קנתה?", |
| "expected_operator": "LINEAR_SYSTEM" |
| }, |
| { |
| "id": "CASE_2_Y12_ALGEBRA_NO_INTENT", |
| "name": "יב' אלגברה - ללא כוונת חקירה", |
| "grade": "יב'", |
| "category": "INVESTIGATION", |
| "math_input": "y = 4x + 3", |
| "text": "מצא את נקודת החיתוך של הישר עם הצירים.", |
| "expected_operator": "ALGEBRA_GENERAL" |
| }, |
| { |
| "id": "CASE_3_Y12_INVESTIGATION_FULL", |
| "name": "יב' חקירה - עם כוונת חקירה", |
| "grade": "יב'", |
| "category": "INVESTIGATION", |
| "math_input": "y = x^2 - 4", |
| "text": "חקור את הפונקציה ומצא נקודות קיצון.", |
| "expected_operator": "DERIVATIVE" |
| } |
| ] |
|
|
| for tc in test_cases: |
| print(f"--- Testing: {tc['name']} ---") |
| |
| |
| context = PipelineContext( |
| grade=tc["grade"], |
| grade_num=12 if "יב" in tc["grade"] else 7, |
| topic=tc["category"], |
| math_input=tc["math_input"], |
| confidence=1.0, |
| original_text=tc["text"], |
| category=tc["category"] |
| ) |
|
|
| |
| result = orchestrator.smart_solver.solve(context) |
| print(f" [SOLVER] Operator Used: {result.operator_used}") |
| print(f" [SOLVER] Success: {result.success}") |
| |
| |
| |
| mock_resp = { |
| "sections": [{ |
| "steps": [{"explanation_text": "נחשב את הנגזרת של הפונקציה כדי למצוא פתרון."}] |
| }], |
| "logic_error": False |
| } |
| |
| from orchestrator import validate_and_sanitize_response |
| validated = validate_and_sanitize_response(mock_resp, category=tc["category"]) |
| |
| if tc["category"] != "INVESTIGATION": |
| print(f" [VALIDATOR] Logic Error Detected (Expected): {validated['logic_error']}") |
| |
| |
| if result.operator_used == tc["expected_operator"]: |
| print(f"✅ PASSED: {tc['id']}\n") |
| else: |
| print(f"❌ FAILED: {tc['id']} - Expected {tc['expected_operator']} but got {result.operator_used}\n") |
|
|
| if __name__ == "__main__": |
| asyncio.run(run_tests()) |