44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import requests
|
|
import json
|
|
import sys
|
|
|
|
# Konfiguration
|
|
API_URL = "http://localhost:8002/chat/" # Port ggf. anpassen
|
|
QUESTION = "Warum nutzen wir Qdrant für mindnet?" # Eine Frage, zu der du Notizen hast
|
|
|
|
def test_chat():
|
|
payload = {
|
|
"message": QUESTION,
|
|
"top_k": 3,
|
|
"explain": True
|
|
}
|
|
|
|
print(f"Sending Question: '{QUESTION}'...")
|
|
|
|
try:
|
|
response = requests.post(API_URL, json=payload)
|
|
response.raise_for_status()
|
|
|
|
data = response.json()
|
|
|
|
print("\n=== RESPONSE ===")
|
|
print(data["answer"])
|
|
print("================\n")
|
|
|
|
print(f"Query ID: {data['query_id']}")
|
|
print(f"Latency: {data['latency_ms']}ms")
|
|
print("\nUsed Sources:")
|
|
for source in data["sources"]:
|
|
score = source.get("total_score", 0)
|
|
note = source.get("note_id", "unknown")
|
|
print(f"- {note} (Score: {score:.3f})")
|
|
|
|
except requests.exceptions.ConnectionError:
|
|
print("Error: Could not connect to API. Is it running on port 8002?")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
if 'response' in locals():
|
|
print(response.text)
|
|
|
|
if __name__ == "__main__":
|
|
test_chat() |