Class: SkillBench::Tools::ReadFile
- Defined in:
- lib/skill_bench/tools/read_file.rb
Overview
Handles reading the contents of a file within the working directory.
Class Method Summary collapse
-
.call(path, working_dir_path) ⇒ String
Reads the contents of a file.
-
.definition ⇒ Hash
The tool definition for the LLM API.
Class Method Details
.call(path, working_dir_path) ⇒ String
Reads the contents of a file.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/skill_bench/tools/read_file.rb', line 34 def self.call(path, working_dir_path) validation_error = validate_read_file_path(path) return validation_error if validation_error target = secure_path(path, working_dir_path) return 'Error: File not found' unless target.exist? && target.file? return 'Error: File is not readable' unless target.readable? target.read rescue ArgumentError raise rescue StandardError => e SkillBench::ErrorLogger.log_error(e, 'ReadFile Error') "Error reading file: #{e.}" end |
.definition ⇒ Hash
Returns The tool definition for the LLM API.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/skill_bench/tools/read_file.rb', line 11 def self.definition { type: 'function', function: { name: 'read_file', description: 'Read the contents of a file.', parameters: { type: 'object', properties: { path: { type: 'string', description: 'Relative path to the file to read.' } }, required: ['path'], additionalProperties: false } } } end |