-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_serper_tools_format.py
More file actions
49 lines (41 loc) · 1.86 KB
/
test_serper_tools_format.py
File metadata and controls
49 lines (41 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from search_tools_serper import serper_search_tool, serper_scholar_tool
def test_search_tool_format():
print("\nTesting Internet Search with agent-style input format...")
try:
# Test with the exact format the agent uses
result = serper_search_tool.run("latest developments in artificial intelligence")
print("✅ Search successful!")
print("\nSample results:")
print(result[:500] + "..." if len(result) > 500 else result)
except Exception as e:
print(f"❌ Search failed with error: {str(e)}")
def test_scholar_tool_format():
print("\nTesting Scholar Search with agent-style input format...")
try:
# Test with the exact format the agent uses
result = serper_scholar_tool.run("machine learning neural networks")
print("✅ Scholar search successful!")
print("\nSample results:")
print(result[:500] + "..." if len(result) > 500 else result)
except Exception as e:
print(f"❌ Scholar search failed with error: {str(e)}")
def test_scholar_tool_without_num_results():
print("\nTesting Scholar Search with minimal input format...")
try:
# Test with just the required parameter
result = serper_scholar_tool.run("artificial intelligence ethics")
print("✅ Scholar search (without num_results) successful!")
print("\nSample results:")
print(result[:500] + "..." if len(result) > 500 else result)
except Exception as e:
print(f"❌ Scholar search failed with error: {str(e)}")
if __name__ == "__main__":
print("Testing Serper tools with agent-style input format...")
print("=" * 80)
test_search_tool_format()
print("\n" + "=" * 80)
test_scholar_tool_format()
print("\n" + "=" * 80)
test_scholar_tool_without_num_results()
print("\n" + "=" * 80)
print("\nTests completed!")