50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
import requests
|
|
import json
|
|
|
|
def check_search_results():
|
|
base_url = 'http://localhost:3015'
|
|
headers = {'X-API-Key': 'jleu1212', 'Content-Type': 'application/json'}
|
|
|
|
# Test different search queries
|
|
queries = ['screenshot', 'bee', 'photo of a bee', 'image classification', 'insect']
|
|
|
|
for query in queries:
|
|
print(f"\n🔍 Testing search for: '{query}'")
|
|
try:
|
|
response = requests.post(
|
|
f'{base_url}/api/search',
|
|
headers=headers,
|
|
json={'query': query, 'top_k': 10},
|
|
timeout=20
|
|
)
|
|
print(f'Status: {response.status_code}')
|
|
|
|
if response.status_code == 200:
|
|
results = response.json()
|
|
chunks = results.get('chunks', [])
|
|
print(f'Chunks found: {len(chunks)}')
|
|
|
|
if chunks:
|
|
entities = results.get('entities', [])
|
|
print(f'Entities found: {len(entities)}')
|
|
if entities:
|
|
print('Entities:')
|
|
for entity in entities:
|
|
print(f' - {entity}')
|
|
|
|
for i, chunk in enumerate(chunks[:3]): # Show first 3 chunks
|
|
print(f'Chunk {i+1}:')
|
|
file_path = chunk.get('file_path', 'Unknown')
|
|
content = chunk.get('content', '')
|
|
print(f' File: {file_path}')
|
|
print(f' Content preview: {content[:200]}...')
|
|
else:
|
|
print('No chunks found for this query')
|
|
else:
|
|
print(f'Error: {response.text}')
|
|
|
|
except Exception as e:
|
|
print(f'Exception: {e}')
|
|
|
|
if __name__ == '__main__':
|
|
check_search_results() |