29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import requests
|
|
|
|
def search_multiple_terms():
|
|
base_url = 'http://localhost:3015'
|
|
headers = {'X-API-Key': 'jleu1212', 'Content-Type': 'application/json'}
|
|
|
|
# Search for different terms to see what's indexed
|
|
queries = ['bee', 'photo of a bee', 'Image Classifications:', 'Docker for windows']
|
|
|
|
for query in queries:
|
|
print(f'🔍 Searching for: {query}')
|
|
try:
|
|
response = requests.post(f'{base_url}/api/search', headers=headers, json={'query': query, 'top_k': 10}, timeout=20)
|
|
if response.status_code == 200:
|
|
results = response.json()
|
|
chunks = results.get('chunks', [])
|
|
print(f' Results: {len(chunks)} chunks')
|
|
for chunk in chunks:
|
|
file_path = chunk.get('file_path', 'Unknown')
|
|
content = chunk.get('content', '')[:100]
|
|
print(f' - {file_path}: {content}...')
|
|
else:
|
|
print(f' Error: {response.status_code}')
|
|
except Exception as e:
|
|
print(f' Exception: {e}')
|
|
print()
|
|
|
|
if __name__ == '__main__':
|
|
search_multiple_terms() |