testscript
This commit is contained in:
parent
86464cec11
commit
ff23ce6f00
|
|
@ -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", "")
|
||||
# Testfall: Muss INTERVIEW auslösen
|
||||
test_intent("Ich möchte ein neues Projekt anlegen")
|
||||
Loading…
Reference in New Issue
Block a user