Spaces:
Sleeping
Sleeping
File size: 1,020 Bytes
5c095ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # Run this in a SEPARATE terminal while run_api.py is running
import requests
import json
BASE_URL = "http://localhost:8000"
# Test 1: Health check
print("Testing /health...")
r = requests.get(f"{BASE_URL}/health")
print(json.dumps(r.json(), indent=2))
# Test 2: Query
print("\nTesting /query...")
payload = {
"question": "What is LoRA and how does it work?",
"top_k": 5
}
r = requests.post(f"{BASE_URL}/query", json=payload)
data = r.json()
print(f"Answer: {data['answer'][:300]}...")
print(f"\nCitations: {len(data['citations'])}")
for c in data['citations']:
print(f" - {c['paper_id']}: {c['title'][:50]}...")
print(f"\nTotal time: {data['total_time_ms']:.0f}ms")
# Test 3: Filtered query
print("\nTesting /query with filter...")
payload = {
"question": "graph neural network applications",
"top_k": 3,
"filter_year_gte": 2026
}
r = requests.post(f"{BASE_URL}/query", json=payload)
data = r.json()
print(f"Answer: {data['answer'][:200]}...")
print(f"Citations: {len(data['citations'])}") |