Class: SharedTools::Tools::DocTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::DocTool
- Defined in:
- lib/shared_tools/tools/doc_tool.rb
Overview
A tool for reading and processing documents
Defined Under Namespace
Modules: Action
Constant Summary collapse
- ACTIONS =
[ Action::PDF_READ, ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(action:, doc_path: nil, page_numbers: nil) ⇒ Hash
Execution result.
-
#initialize(logger: nil) ⇒ DocTool
constructor
A new instance of DocTool.
Constructor Details
#initialize(logger: nil) ⇒ DocTool
Returns a new instance of DocTool.
67 68 69 |
# File 'lib/shared_tools/tools/doc_tool.rb', line 67 def initialize(logger: nil) @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
9 |
# File 'lib/shared_tools/tools/doc_tool.rb', line 9 def self.name = 'doc_tool' |
Instance Method Details
#execute(action:, doc_path: nil, page_numbers: nil) ⇒ Hash
Returns execution result.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/shared_tools/tools/doc_tool.rb', line 76 def execute(action:, doc_path: nil, page_numbers: nil) @logger.info("DocTool#execute action=#{action}") case action.to_s.downcase when Action::PDF_READ require_param!(:doc_path, doc_path) require_param!(:page_numbers, page_numbers) pdf_reader_tool.execute(doc_path: doc_path, page_numbers: page_numbers) else { error: "Unsupported action: #{action}. Supported actions are: #{ACTIONS.join(', ')}" } end rescue StandardError => e @logger.error("DocTool execution failed: #{e.message}") { error: e. } end |