| import requests |
| import base64 |
| import json |
| import time |
| import os |
| import sys |
|
|
| |
| API_URL = "http://127.0.0.1:8000/solve_stream" |
| TEST_IMAGE_PATH = "test_image.png" |
|
|
| def run_inspection_safe(): |
| print("๐ SAFETY CHECK: This script will trigger 1 LLM call.") |
| print(" Estimated cost: $0.0016") |
| confirm = input(" Type 'yes' to proceed: ") |
| |
| if confirm.lower() != 'yes': |
| print("โ Aborted by user.") |
| return |
|
|
| |
| print("\n๐ Starting Single Run Inspection...") |
| |
| if not os.path.exists(TEST_IMAGE_PATH): |
| print(f"โ Error: Image file '{TEST_IMAGE_PATH}' not found.") |
| return |
|
|
| files = {'file': ('test.png', open(TEST_IMAGE_PATH, 'rb'), 'image/png')} |
| data = {'grade': 'Test', 'mode': 'solve', 'student_name': 'Tester'} |
|
|
| try: |
| start_time = time.time() |
| |
| response = requests.post(API_URL, files=files, data=data, timeout=60) |
| |
| print(f"โ
Status Code: {response.status_code}") |
| print(f"โฑ๏ธ Time: {time.time() - start_time:.2f}s") |
| |
| if response.status_code == 200: |
| try: |
| data = response.json() |
| print("โ
JSON Valid") |
| print(f"๐ Keys found: {list(data.keys())}") |
| if "sections" in data: |
| print(f"๐ Sections count: {len(data['sections'])}") |
| except: |
| print("โ ๏ธ Not a JSON response") |
| print(response.text[:200]) |
| else: |
| print("โ Server Error") |
| print(response.text) |
|
|
| except Exception as e: |
| print(f"โ Connection Error: {e}") |
|
|
| if __name__ == "__main__": |
| run_inspection_safe() |