| |
| """H4 Multi-Agent Coordination Tests (n=10)""" |
| import requests |
| import time |
| import json |
|
|
| BASE_URL = "http://localhost:8000/api/v1/multi-agent/chat" |
|
|
| test_cases = [ |
| {"scenario": "Medizin", "message": "Was sind die Nebenwirkungen von Ibuprofen?"}, |
| {"scenario": "Medizin", "message": "Welche Symptome deuten auf Migräne hin?"}, |
| {"scenario": "Entwicklung", "message": "Wie implementiere ich ein REST API in Python?"}, |
| {"scenario": "Entwicklung", "message": "Was ist der Unterschied zwischen async und sync?"}, |
| {"scenario": "Finanzen", "message": "Wie berechne ich den ROI einer Investition?"}, |
| {"scenario": "Finanzen", "message": "Was sind die Grundlagen der Budgetplanung?"}, |
| {"scenario": "Recht", "message": "Was sind die wichtigsten DSGVO-Anforderungen?"}, |
| {"scenario": "System", "message": "Wie konfiguriere ich Docker Compose?"}, |
| {"scenario": "Coaching", "message": "Strategien für effektives Zeitmanagement?"}, |
| {"scenario": "Allgemein", "message": "Erkläre Multi-Agent-Systeme"}, |
| ] |
|
|
| results = [] |
| print("=" * 70) |
| print("H4 MULTI-AGENT KOORDINATION TESTS (n=10)") |
| print("=" * 70) |
|
|
| for i, test in enumerate(test_cases, 1): |
| print(f"\nTest {i}/10: {test['scenario']}") |
| start_time = time.time() |
| try: |
| response = requests.post(BASE_URL, json={ |
| "user_message": test["message"], "privacy_mode": "auto" |
| }, timeout=60) |
| latency = time.time() - start_time |
| data = response.json() |
| result = { |
| "test_nr": i, "scenario": test["scenario"], |
| "latency_s": round(latency, 2), |
| "success": data.get("success", False), |
| "specialist": data.get("specialist_agent", "N/A"), |
| "delegation": data.get("delegation_used", False), |
| "provider": data.get("response", {}).get("provider", "N/A"), |
| } |
| results.append(result) |
| print(f" Latenz: {latency:.2f}s | Specialist: {result['specialist']}") |
| except Exception as e: |
| print(f" FEHLER: {e}") |
| results.append({"test_nr": i, "scenario": test["scenario"], "latency_s": 0, "success": False}) |
|
|
| |
| successful = [r for r in results if r.get("success")] |
| latencies = [r["latency_s"] for r in successful] |
| if latencies: |
| avg = sum(latencies) / len(latencies) |
| std_dev = (sum((x - avg) ** 2 for x in latencies) / len(latencies)) ** 0.5 |
| print(f"\n{'='*70}\nSTATISTIK: n={len(latencies)}, x̄={avg:.2f}s, min={min(latencies):.2f}s, max={max(latencies):.2f}s, σ={std_dev:.2f}s") |
| print(f"Erfolgsrate: {len(successful)/len(results)*100:.0f}%") |
|
|
| print(f"\n{'='*70}\nROHDATEN:") |
| for r in results: |
| print(f" T{r['test_nr']}: {r['latency_s']}s | {r.get('specialist','N/A')} | {'✓' if r.get('success') else '✗'}") |
|
|