| import sys |
| import os |
| import time |
|
|
| |
| if sys.platform == "win32": |
| sys.stdout.reconfigure(encoding='utf-8') |
|
|
| |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) |
|
|
| from src.rag_engine import SatelliteRAG |
|
|
| def run_tests(): |
| print("Initializing SatelliteRAG Engine...") |
| try: |
| engine = SatelliteRAG() |
| print("[OK] Engine Initialized Successfully.") |
| except Exception as e: |
| print(f"[ERROR] Failed to initialize engine: {e}") |
| return |
|
|
| questions = [ |
| |
| "What is the launch mass of Chang'e 5?", |
| "Who operates the Fengyun satellites?", |
| "List the instruments on ZY-3 01.", |
| |
| |
| "How many communication satellites are there? List examples.", |
| "What categories of satellites does China have?", |
| |
| |
| "What is the difference between Gaofen 1 and Gaofen 2?", |
| "Compare the orbits of Beidou-2 and Beidou-3 satellites.", |
| |
| |
| "When was the first Dong Fang Hong satellite launched?", |
| "What is the purpose of the Shiyan 10 satellite?", |
| "Which rocket launched the Tianwen-1 mission?", |
| "What is the resolution of Gaofen 7?", |
| |
| |
| "List three Earth Observation satellites.", |
| "Name two satellites launched in 2022.", |
| |
| |
| "Who is the CEO of SpaceX?", |
| "What is the price of a ticket to the moon?", |
| |
| |
| "Describe the payload of the TanSat satellite.", |
| "What is the lifetime of the Tiangong-2 space station?", |
| "Which satellite uses the Phoenix-Eye-1 bus?", |
| "Who manufactured the APStar 6D satellite?", |
| "What is the COSPAR ID of Yaogan 30-01?" |
| ] |
|
|
| print(f"\n[START] Starting Test Suite: {len(questions)} Questions\n" + "="*50) |
| |
| results = [] |
| |
| for i, q in enumerate(questions, 1): |
| print(f"\n[Test {i}/{len(questions)}] Question: {q}") |
| start_time = time.time() |
| try: |
| answer, docs = engine.query(q) |
| elapsed = time.time() - start_time |
| |
| print(f"[Time]: {elapsed:.2f}s") |
| print(f"[Answer]: {answer.strip()[:200]}...") |
| print(f"[Sources]: {[d.metadata.get('name') for d in docs[:3]]}") |
| |
| |
| if "I don't have" in answer and "CEO" not in q and "price" not in q: |
| status = "[POTENTIAL FAIL] (No Data)" |
| elif "CEO" in q and "I don't have" not in answer: |
| status = "[POTENTIAL FAIL] (Hallucination)" |
| else: |
| status = "[PASS]" |
| |
| print(f"Status: {status}") |
| results.append((q, status, elapsed)) |
| |
| except Exception as e: |
| print(f" ERROR: {e}") |
| results.append((q, "ERROR", 0)) |
|
|
| print("\n" + "="*50) |
| print("Test Summary") |
| print("="*50) |
| for q, status, elapsed in results: |
| print(f"{status} | {elapsed:.2f}s | {q}") |
|
|
| if __name__ == "__main__": |
| run_tests() |
|
|