You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

#!/usr/bin/env python3
"""
只测试网页搜索功能
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from deepsearcher.web_search import WebSearch
def test_web_search():
"""测试网页搜索功能"""
print("=== 测试网页搜索功能 ===")
# 初始化网页搜索
web_search = WebSearch()
# 测试查询
test_query = "Milvus是什么"
print(f"测试查询: {test_query}")
# 执行搜索
results = web_search.search_with_retry(test_query, size=4)
if results:
print(f"✅ 成功找到 {len(results)} 个搜索结果:")
for i, result in enumerate(results, 1):
print(f"\n--- 结果 {i} ---")
print(f"标题: {result.metadata.get('title', 'N/A')}")
print(f"链接: {result.reference}")
print(f"分数: {result.score}")
print(f"内容长度: {len(result.text)} 字符")
print(f"内容预览: {result.text[:200]}...")
print(f"来源: {result.metadata.get('source', 'N/A')}")
else:
print("❌ 未找到搜索结果")
if __name__ == "__main__":
test_web_search()