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() # Timeout חובה! מונע המתנה אינסופית 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()