Class: RCrewAI::Tools::WebSearch
- Defined in:
- lib/rcrewai/tools/web_search.rb
Constant Summary
Constants included from RCrewAI::ToolSchema
Instance Method Summary collapse
- #execute(**params) ⇒ Object
-
#initialize(**options) ⇒ WebSearch
constructor
A new instance of WebSearch.
Methods inherited from Base
available_tools, create_tool, #description, #execute_with_validation, #json_schema, list_available_tools, #name, #validate_params!
Methods included from RCrewAI::ToolSchema
#description, extended, #json_schema, #param, #params, #tool_name
Constructor Details
#initialize(**options) ⇒ WebSearch
Returns a new instance of WebSearch.
18 19 20 21 22 |
# File 'lib/rcrewai/tools/web_search.rb', line 18 def initialize(**) super() @max_results = .fetch(:max_results, 5) @timeout = .fetch(:timeout, 30) end |
Instance Method Details
#execute(**params) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rcrewai/tools/web_search.rb', line 24 def execute(**params) validate_params!(params, required: [:query], optional: [:max_results]) query = params[:query] max_results = params[:max_results] || @max_results begin search_results = perform_search(query, max_results) format_results(search_results) rescue StandardError => e "Search failed: #{e.}" end end |