Files
railseek6/test_rerank.py
2026-01-13 09:51:35 +08:00

53 lines
1.6 KiB
Python

import requests
import json
# Test query with enable_rerank=True
url = "http://localhost:3015/query"
headers = {
"Content-Type": "application/json",
"X-API-Key": "jleu1212"
}
data = {
"query": "test query",
"enable_rerank": True,
"only_need_context": True # Get only context to see what's retrieved
}
try:
response = requests.post(url, headers=headers, json=data, timeout=10)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
if response.status_code == 200:
result = response.json()
print(f"\nQuery successful")
print(f"Response length: {len(result.get('response', ''))}")
# Try to parse if it's JSON
try:
parsed = json.loads(result.get('response', '{}'))
print(f"Parsed response type: {type(parsed)}")
if isinstance(parsed, dict):
print(f"Has metadata: {'metadata' in parsed}")
if 'metadata' in parsed:
print(f"Metadata keys: {list(parsed['metadata'].keys())}")
except:
print("Response is not JSON")
except Exception as e:
print(f"Error: {e}")
# Also test without rerank for comparison
print("\n" + "="*50)
print("Testing without rerank:")
data_no_rerank = {
"query": "test query",
"enable_rerank": False,
"only_need_context": True
}
try:
response = requests.post(url, headers=headers, json=data_no_rerank, timeout=10)
print(f"Status Code: {response.status_code}")
print(f"Response length: {len(response.text)}")
except Exception as e:
print(f"Error: {e}")