48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import requests
|
|
import json
|
|
|
|
# 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):
|
|
payload = {
|
|
"message": message,
|
|
"top_k": 0, # Für Interview irrelevant
|
|
"explain": False
|
|
}
|
|
|
|
try:
|
|
response = requests.post(API_URL, json=payload)
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
|
|
intent = data.get("intent")
|
|
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")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error: {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", "") |