#!/usr/bin/env python3 """ Quick test to see what the model is actually predicting """ import requests import json BASE_URL = "http://localhost:8000" def test_single_prediction(): """Test a single prediction to see raw output""" # Test obvious hallucination payload = { "prompt": "Question: What is the capital of France?", "response": "London is the capital of France", "question": "What is the capital of France?" } print("๐Ÿงช Testing obvious hallucination:") print(f"Question: {payload['question']}") print(f"Response: {payload['response']}") print(f"Expected: HALLUCINATION") print() try: response = requests.post(f"{BASE_URL}/api/debug-predict", json=payload, timeout=10) if response.status_code == 200: result = response.json() print("๐Ÿ“Š Debug Results:") print(f"Raw Model Output: '{result.get('raw_model_output', '')}'") print(f"Extracted Prediction: '{result.get('extracted_prediction', '')}'") print(f"Is Hallucination: {result.get('is_hallucination', False)}") print(f"Confidence Score: {result.get('confidence_score', 0):.3f}") print() # Also test regular API response2 = requests.post(f"{BASE_URL}/api/predict", json=payload, timeout=10) if response2.status_code == 200: result2 = response2.json() print("๐Ÿ“Š Regular API Results:") print(f"Is Hallucination: {result2.get('is_hallucination', False)}") print(f"Confidence Score: {result2.get('confidence_score', 0):.3f}") print(f"Raw Prediction: '{result2.get('raw_prediction', '')}'") else: print(f"โŒ Error: {response.status_code}") print(response.text) except Exception as e: print(f"โŒ Error: {e}") if __name__ == "__main__": test_single_prediction()