| import asyncio |
| import os |
| import sys |
| import json |
| from dotenv import load_dotenv |
|
|
| |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
|
| from buddy_math_server.orchestrator import BuddyOrchestrator |
|
|
| |
| MOCK_IMAGE = b'GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\xff\xff\xff!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x01D\x00;' |
|
|
| async def test_pipeline(): |
| print("๐ Starting Backend Pipeline Verification...") |
| |
| |
| load_dotenv() |
| if not os.getenv("GOOGLE_API_KEY"): |
| print("โ GOOGLE_API_KEY not found in environment!") |
| return |
|
|
| try: |
| |
| print("๐น Initializing BuddyOrchestrator...") |
| orchestrator = BuddyOrchestrator() |
| |
| |
| print("\n๐งช Test Case 1: Geometry Problem with Image") |
| problem_text = """ |
| ืืืฉืืืฉ ืืฉืจ ืืืืืช ABC, ืืืชืจ ืืื 10 ืก"ื. |
| ื. ืืฆื ืืช ืืืจื ืื ืืฆื ืื ืื ืืฆื ืืฉื ื ืืื 6. |
| ื. ืืฉื ืืช ืฉืื ืืืฉืืืฉ. |
| """ |
| |
| |
| |
| print("๐น Calling solve_problem...") |
| result = await orchestrator.solve_problem( |
| problem_text=problem_text, |
| grade="10", |
| student_name="TestUser", |
| student_gender="M", |
| image_data=MOCK_IMAGE |
| ) |
| |
| print("\nโ
Pipeline Execution Successful!") |
| print("๐ Result Keys:", result.keys()) |
| |
| if "sections" in result: |
| print(f"โ
Generated {len(result['sections'])} sections") |
| for s in result['sections']: |
| print(f" - {s.get('section_title')}") |
| else: |
| print("โ ๏ธ No sections found in result (might be legacy fallback?)") |
| print("Result dump:", json.dumps(result, ensure_ascii=False)[:200] + "...") |
|
|
| except Exception as e: |
| print(f"\nโ Pipeline Verified FAILED: {e}") |
| import traceback |
| traceback.print_exc() |
|
|
| if __name__ == "__main__": |
| asyncio.run(test_pipeline()) |
|
|