Class: Rubino::Tools::WebSearchTool
- Inherits:
-
Base
- Object
- Base
- Rubino::Tools::WebSearchTool
show all
- Defined in:
- lib/rubino/tools/websearch_tool.rb
Overview
Tool for performing web searches via external search APIs. Supports Tavily, SearXNG, and a fallback DuckDuckGo scraper.
Instance Attribute Summary
Attributes inherited from Base
#cancel_token, #read_tracker, #stream_chunk
Instance Method Summary
collapse
Methods inherited from Base
#cancellation_requested?, #emit_chunk, #risky?, #to_tool_definition, workspace_root, workspace_roots
Instance Method Details
#call(arguments) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rubino/tools/websearch_tool.rb', line 48
def call(arguments)
query = arguments["query"] || arguments[:query]
max_results = arguments["max_results"] || arguments[:max_results] || 5
if ENV["TAVILY_API_KEY"]
search_tavily(query, max_results)
elsif ENV["SEARXNG_URL"]
search_searxng(query, max_results)
else
search_ddg(query, max_results)
end
rescue StandardError => e
"Search error: #{e.message}"
end
|
#config_key ⇒ Object
Gated by ‘tools.web` (shared with webfetch), not `tools.websearch`.
17
18
19
|
# File 'lib/rubino/tools/websearch_tool.rb', line 17
def config_key
"web"
end
|
#description ⇒ Object
21
22
23
24
25
|
# File 'lib/rubino/tools/websearch_tool.rb', line 21
def description
"Search the web for information. Returns relevant results with titles, " \
"URLs, and snippets. Useful for finding documentation, researching " \
"dependencies, and answering questions about external topics."
end
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rubino/tools/websearch_tool.rb', line 27
def input_schema
{
type: "object",
properties: {
query: {
type: "string",
description: "The search query"
},
max_results: {
type: "integer",
description: "Maximum number of results (default: 5)"
}
},
required: %w[query]
}
end
|
#name ⇒ Object
12
13
14
|
# File 'lib/rubino/tools/websearch_tool.rb', line 12
def name
"websearch"
end
|
#risk_level ⇒ Object
44
45
46
|
# File 'lib/rubino/tools/websearch_tool.rb', line 44
def risk_level
:low
end
|