From ff23ce6f00cab5402e4308d5d1ad9d7477bbc373 Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 10 Dec 2025 14:03:07 +0100 Subject: [PATCH] testscript --- tests/test_interview_intent.py | 54 +++++++++++++++------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/tests/test_interview_intent.py b/tests/test_interview_intent.py index f61b611..b847984 100644 --- a/tests/test_interview_intent.py +++ b/tests/test_interview_intent.py @@ -1,48 +1,40 @@ import requests -import json +import sys -# URL anpassen, falls du auf Port 8001 (Prod) oder 8002 (Dev) bist API_URL = "http://localhost:8002/chat/" -def test_intent(message, expected_intent, expected_type_hint): +def test_intent(message): + print(f"📡 Sende: '{message}' ...") payload = { "message": message, - "top_k": 0, # Für Interview irrelevant + "top_k": 0, "explain": False } try: - response = requests.post(API_URL, json=payload) - response.raise_for_status() - data = response.json() + # Timeout nach 30 Sekunden erzwingen + response = requests.post(API_URL, json=payload, timeout=30) + if response.status_code != 200: + print(f"❌ Server Error {response.status_code}: {response.text}") + return + + data = response.json() intent = data.get("intent") + source = data.get("intent_source") answer = data.get("answer") - print(f"--- TEST: '{message}' ---") - print(f"Erkannter Intent: {intent}") - print(f"Antwort-Snippet: {answer[:100]}...") - - if intent == expected_intent: - print("✅ Intent SUCCESS") - else: - print(f"❌ Intent FAILED (Erwartet: {expected_intent})") - - if expected_type_hint.lower() in answer.lower(): - print(f"✅ Context Check SUCCESS (Typ '{expected_type_hint}' erkannt)") - else: - print(f"⚠️ Context Check WARNING (Typ '{expected_type_hint}' nicht explizit im Start-Prompt gefunden)") - print("\n") - + print(f"✅ Ergebnis erhalten:") + print(f" Intent: {intent} (Quelle: {source})") + print(f" Antwort: {answer[:100]}...") # Nur die ersten 100 Zeichen + print("-" * 40) + + except requests.exceptions.Timeout: + print("❌ TIMEOUT: Das Backend antwortet nicht innerhalb von 30 Sekunden.") + print(" -> Prüfe das Terminal, wo uvicorn läuft. Gibt es dort Fehlermeldungen?") except Exception as e: - print(f"❌ Error: {e}") + print(f"❌ Fehler: {e}") if __name__ == "__main__": - # Test 1: Projekt-Start - test_intent("Ich möchte ein neues Projekt anlegen", "INTERVIEW", "project") - - # Test 2: Entscheidungs-Doku - test_intent("Lass uns eine Entscheidung festhalten", "INTERVIEW", "decision") - - # Test 3: Standard Chat (Gegenprobe) - test_intent("Was ist ein Vektor?", "FACT", "") \ No newline at end of file + # Testfall: Muss INTERVIEW auslösen + test_intent("Ich möchte ein neues Projekt anlegen") \ No newline at end of file