jina rerank working
This commit is contained in:
74
test_current_rerank_behavior.py
Normal file
74
test_current_rerank_behavior.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test current Jina rerank behavior with the server"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
|
||||
def test_rerank_behavior():
|
||||
print("=== Testing Current Rerank Behavior ===")
|
||||
|
||||
# Test query with rerank enabled
|
||||
test_query = {
|
||||
"query": "what is odds",
|
||||
"workspace": "test1",
|
||||
"enable_rerank": True,
|
||||
"top_k": 5
|
||||
}
|
||||
|
||||
print(f"Query: {test_query}")
|
||||
|
||||
try:
|
||||
start_time = time.time()
|
||||
response = requests.post(
|
||||
"http://localhost:3015/api/query",
|
||||
json=test_query,
|
||||
headers={"Content-Type": "application/json"},
|
||||
timeout=30
|
||||
)
|
||||
elapsed_time = time.time() - start_time
|
||||
|
||||
print(f"\nResponse Status: {response.status_code}")
|
||||
print(f"Response Time: {elapsed_time:.2f} seconds")
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print(f"\n✓ Query successful")
|
||||
print(f"Response keys: {list(result.keys())}")
|
||||
|
||||
# Check if rerank was used
|
||||
if "rerank_scores" in result:
|
||||
print(f"\n✓ Rerank scores found: {result['rerank_scores']}")
|
||||
else:
|
||||
print(f"\n✗ No rerank scores in response")
|
||||
|
||||
# Check response time indication
|
||||
if elapsed_time > 5:
|
||||
print(f"⚠ Long response time ({elapsed_time:.2f}s) suggests rerank might be attempting to call external API")
|
||||
else:
|
||||
print(f"✓ Normal response time")
|
||||
|
||||
elif response.status_code == 500:
|
||||
error_text = response.text
|
||||
print(f"\n✗ Server error (500)")
|
||||
print(f"Error: {error_text[:500]}...")
|
||||
|
||||
# Check for Jina API key error
|
||||
if "api.jina.ai" in error_text or "JINA_API_KEY" in error_text:
|
||||
print("\n⚠ Detected Jina Cloud API error - needs API key or local configuration")
|
||||
elif "timeout" in error_text.lower():
|
||||
print("\n⚠ Timeout error - external API might be unreachable")
|
||||
|
||||
else:
|
||||
print(f"\n✗ Unexpected status: {response.status_code}")
|
||||
print(f"Response: {response.text[:500]}...")
|
||||
|
||||
except requests.exceptions.Timeout:
|
||||
print(f"\n✗ Request timeout (30s) - rerank might be stuck trying to reach external API")
|
||||
except requests.exceptions.ConnectionError:
|
||||
print(f"\n✗ Connection error - server might not be running")
|
||||
except Exception as e:
|
||||
print(f"\n✗ Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_rerank_behavior()
|
||||
Reference in New Issue
Block a user