60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Test script to check if search functionality is working
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import asyncio
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from execution.search_executor import SearchExecutor
|
|
from query.query_processor import QueryProcessor
|
|
|
|
async def test_search():
|
|
"""Test search functionality"""
|
|
query = "Research and explain in detail the potential effects of creatine supplementation on muscle mass and strength"
|
|
|
|
# Initialize components
|
|
query_processor = QueryProcessor()
|
|
search_executor = SearchExecutor()
|
|
|
|
# Print available search engines
|
|
available_engines = search_executor.get_available_search_engines()
|
|
print(f"Available search engines: {available_engines}")
|
|
|
|
# Process the query
|
|
structured_query = query_processor.process_query(query)
|
|
print(f"Structured query: {json.dumps(structured_query, indent=2)}")
|
|
|
|
# Generate search queries for different engines
|
|
structured_query = query_processor.generate_search_queries(
|
|
structured_query,
|
|
search_executor.get_available_search_engines()
|
|
)
|
|
print(f"Search queries: {json.dumps(structured_query.get('search_queries', {}), indent=2)}")
|
|
|
|
# Execute search
|
|
search_results = search_executor.execute_search(
|
|
structured_query,
|
|
num_results=5
|
|
)
|
|
|
|
# Print results
|
|
for engine, results in search_results.items():
|
|
print(f"\nResults from {engine}: {len(results)}")
|
|
for i, result in enumerate(results[:3]): # Show first 3 results
|
|
print(f" {i+1}. {result.get('title')} - {result.get('url')}")
|
|
|
|
# Return total number of results
|
|
total_results = sum(len(results) for results in search_results.values())
|
|
return total_results
|
|
|
|
if __name__ == "__main__":
|
|
total_results = asyncio.run(test_search())
|
|
print(f"\nTotal results: {total_results}")
|