110 lines
4.0 KiB
Python
110 lines
4.0 KiB
Python
import requests
|
||
import json
|
||
import time
|
||
|
||
# Test query for workspace test1
|
||
url = "http://localhost:3015/query"
|
||
headers = {
|
||
"Content-Type": "application/json",
|
||
"X-API-Key": "jleu1212",
|
||
"X-Workspace": "test1" # Specify workspace
|
||
}
|
||
|
||
query = "what is odds"
|
||
|
||
print(f"Testing query: '{query}' for workspace: test1")
|
||
print("="*60)
|
||
|
||
# Test 1: With rerank enabled
|
||
print("\n1. Testing WITH rerank enabled (enable_rerank=True):")
|
||
data_with_rerank = {
|
||
"query": query,
|
||
"enable_rerank": True,
|
||
"only_need_context": True # Get context to see what's retrieved
|
||
}
|
||
|
||
try:
|
||
start_time = time.time()
|
||
response = requests.post(url, headers=headers, json=data_with_rerank, timeout=30)
|
||
elapsed = time.time() - start_time
|
||
|
||
print(f" Status Code: {response.status_code}")
|
||
print(f" Response Time: {elapsed:.2f}s")
|
||
|
||
if response.status_code == 200:
|
||
result = response.json()
|
||
response_text = result.get('response', '')
|
||
|
||
# Check for rerank-related messages
|
||
if "Rerank is enabled but no rerank model is configured" in response_text:
|
||
print(" ⚠️ Rerank warning found: 'Rerank is enabled but no rerank model is configured'")
|
||
print(" This means the checkbox works but Jina API is not configured")
|
||
elif "Successfully reranked" in response_text:
|
||
print(" ✅ Rerank success message found!")
|
||
else:
|
||
# Check if we can find any rerank scores in the response
|
||
if "rerank_score" in response_text.lower():
|
||
print(" ✅ Rerank scores found in response!")
|
||
else:
|
||
print(" ℹ️ No rerank indicators found in response")
|
||
|
||
# Show response snippet
|
||
print(f" Response snippet (first 500 chars):")
|
||
print(f" {response_text[:500]}...")
|
||
|
||
except Exception as e:
|
||
print(f" Error: {e}")
|
||
|
||
# Test 2: Without rerank enabled
|
||
print("\n2. Testing WITHOUT rerank enabled (enable_rerank=False):")
|
||
data_without_rerank = {
|
||
"query": query,
|
||
"enable_rerank": False,
|
||
"only_need_context": True
|
||
}
|
||
|
||
try:
|
||
start_time = time.time()
|
||
response = requests.post(url, headers=headers, json=data_without_rerank, timeout=30)
|
||
elapsed = time.time() - start_time
|
||
|
||
print(f" Status Code: {response.status_code}")
|
||
print(f" Response Time: {elapsed:.2f}s")
|
||
|
||
if response.status_code == 200:
|
||
result = response.json()
|
||
response_text = result.get('response', '')
|
||
|
||
# Show response snippet for comparison
|
||
print(f" Response snippet (first 500 chars):")
|
||
print(f" {response_text[:500]}...")
|
||
|
||
except Exception as e:
|
||
print(f" Error: {e}")
|
||
|
||
# Test 3: Check server configuration
|
||
print("\n3. Checking server configuration:")
|
||
try:
|
||
config_response = requests.get("http://localhost:3015/config", headers={"X-API-Key": "jleu1212"})
|
||
if config_response.status_code == 200:
|
||
config = config_response.json()
|
||
print(f" Rerank binding: {config.get('rerank_binding', 'NOT FOUND')}")
|
||
print(f" Rerank model: {config.get('rerank_model', 'NOT FOUND')}")
|
||
print(f" Enable rerank: {config.get('enable_rerank', 'NOT FOUND')}")
|
||
|
||
if config.get('rerank_binding') == 'jina':
|
||
print(" ✅ Server configured for Jina rerank")
|
||
elif config.get('rerank_binding') == 'null':
|
||
print(" ❌ Server NOT configured for rerank (binding=null)")
|
||
else:
|
||
print(f" ℹ️ Rerank binding: {config.get('rerank_binding')}")
|
||
except Exception as e:
|
||
print(f" Error getting config: {e}")
|
||
|
||
print("\n" + "="*60)
|
||
print("ANALYSIS:")
|
||
print("1. Compare response times: Rerank should take longer if calling external API")
|
||
print("2. Check for 'Successfully reranked' or 'rerank_score' in responses")
|
||
print("3. Verify server configuration shows 'rerank_binding: jina'")
|
||
print("4. If 'Rerank is enabled but no rerank model is configured' appears,")
|
||
print(" the checkbox works but Jina API key is missing/invalid") |