update
This commit is contained in:
26
AzA march 2026 - Kopie (18)/_test_live_chat.py
Normal file
26
AzA march 2026 - Kopie (18)/_test_live_chat.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import requests, json
|
||||
|
||||
token = open("backend_token.txt").read().strip()
|
||||
url = open("backend_url.txt").read().strip()
|
||||
|
||||
print(f"Backend-URL: {url}")
|
||||
print(f"Token (erste 8 Zeichen): {token[:8]}...")
|
||||
print()
|
||||
|
||||
r = requests.post(
|
||||
f"{url}/v1/chat",
|
||||
headers={"X-API-Token": token, "Content-Type": "application/json"},
|
||||
json={"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Antworte nur mit OK"}]},
|
||||
timeout=30,
|
||||
)
|
||||
print(f"HTTP Status: {r.status_code}")
|
||||
d = r.json()
|
||||
print(f"success: {d.get('success')}")
|
||||
print(f"content: {d.get('content', '')[:200]}")
|
||||
print(f"model: {d.get('model')}")
|
||||
print(f"duration_ms: {d.get('duration_ms')}")
|
||||
|
||||
if r.status_code == 200 and d.get("success"):
|
||||
print("\n>>> VERBINDUNG ERFOLGREICH: Desktop -> Hetzner -> OpenAI funktioniert!")
|
||||
else:
|
||||
print(f"\n>>> FEHLER: {d.get('error', 'unbekannt')}")
|
||||
Reference in New Issue
Block a user