test
This commit is contained in:
parent
07b7f419de
commit
be5ad7e080
86
tests/test_wp06_decision.py
Normal file
86
tests/test_wp06_decision.py
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
"""
|
||||||
|
tests/test_wp06_decision.py — Integrationstest für WP-06
|
||||||
|
Führt eine Entscheidungsfrage gegen die API aus.
|
||||||
|
"""
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
API_URL = "http://localhost:8000" # Passe Port an, falls nötig (z.B. 8002)
|
||||||
|
|
||||||
|
def test_decision_engine():
|
||||||
|
print("🔵 Starte WP-06 Decision Engine Test...\n")
|
||||||
|
|
||||||
|
# 1. Die Entscheidungsfrage
|
||||||
|
# Das Keyword "Soll ich" triggert die Heuristik in chat.py
|
||||||
|
question = "Soll ich SuperCloud Sync für meine privaten Tagebücher nutzen?"
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"message": question,
|
||||||
|
"top_k": 3,
|
||||||
|
"explain": True
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Request senden
|
||||||
|
print(f"FRAGE: '{question}'")
|
||||||
|
print("... warte auf LLM (kann auf CPU 10-30s dauern) ...")
|
||||||
|
|
||||||
|
response = requests.post(f"{API_URL}/chat/", json=payload, timeout=120)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
# --- CHECKS ---
|
||||||
|
|
||||||
|
# 1. Intent Check
|
||||||
|
intent = data.get("intent", "UNKNOWN")
|
||||||
|
print(f"\n1. INTENT DETECTION: [{'✅' if intent == 'DECISION' else '❌'}]")
|
||||||
|
print(f" Erkannt: {intent} (Erwartet: DECISION)")
|
||||||
|
|
||||||
|
# 2. Source Check (Strategic Retrieval)
|
||||||
|
# Wir suchen nach einer Quelle vom Typ 'value' oder 'principle'
|
||||||
|
sources = data.get("sources", [])
|
||||||
|
found_value = False
|
||||||
|
found_fact = False
|
||||||
|
|
||||||
|
print(f"\n2. STRATEGIC RETRIEVAL:")
|
||||||
|
for i, source in enumerate(sources):
|
||||||
|
# Safe access auf Source-Dict
|
||||||
|
src_meta = source.get("source", {})
|
||||||
|
node_type = src_meta.get("type", "unknown")
|
||||||
|
title = source.get("note_id", "Unknown")
|
||||||
|
|
||||||
|
print(f" [{i+1}] {title} (Typ: {node_type})")
|
||||||
|
|
||||||
|
if node_type in ["value", "principle"]:
|
||||||
|
found_value = True
|
||||||
|
if "SuperCloud" in title or node_type == "concept":
|
||||||
|
found_fact = True
|
||||||
|
|
||||||
|
if found_value and found_fact:
|
||||||
|
print(" ✅ ERFOLG: Fakten UND Werte im Kontext gefunden.")
|
||||||
|
elif found_fact and not found_value:
|
||||||
|
print(" ⚠️ WARNUNG: Nur Fakten gefunden. Values-Injection fehlgeschlagen?")
|
||||||
|
else:
|
||||||
|
print(" ❌ FEHLER: Relevante Quellen fehlen.")
|
||||||
|
|
||||||
|
# 3. Reasoning Check (LLM Antwort)
|
||||||
|
answer = data.get("answer", "")
|
||||||
|
print(f"\n3. REASONING (LLM Antwort):")
|
||||||
|
print("-" * 60)
|
||||||
|
print(answer)
|
||||||
|
print("-" * 60)
|
||||||
|
|
||||||
|
# Einfache Keyword-Prüfung in der Antwort
|
||||||
|
keywords_negative = ["nein", "nicht nutzen", "abraten", "konflikt", "verboten"]
|
||||||
|
if any(k in answer.lower() for k in keywords_negative):
|
||||||
|
print("\n✅ FAZIT: Das System rät korrekt ab (basierend auf 'Privacy_First').")
|
||||||
|
else:
|
||||||
|
print("\n⚠️ FAZIT: Antwort scheint nicht strikt abzulehnen. Prüfe Prompt.")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\n❌ CRITICAL ERROR: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_decision_engine()
|
||||||
Loading…
Reference in New Issue
Block a user