40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import requests
|
|
import sys
|
|
|
|
API_URL = "http://localhost:8002/chat/"
|
|
|
|
def test_intent(message):
|
|
print(f"📡 Sende: '{message}' ...")
|
|
payload = {
|
|
"message": message,
|
|
"top_k": 0,
|
|
"explain": False
|
|
}
|
|
|
|
try:
|
|
# 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"✅ 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"❌ Fehler: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
# Testfall: Muss INTERVIEW auslösen
|
|
test_intent("Ich möchte ein neues Projekt anlegen") |