Class: ActAsAgent::Tools::ReadFile
- Inherits:
-
Object
- Object
- ActAsAgent::Tools::ReadFile
- Defined in:
- lib/act_as_agent/tools/read_file.rb
Constant Summary collapse
- ERROR =
ActAsAgent::Errors::ToolIncorrectArgsError
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #call(args = {}) ⇒ Object
- #description ⇒ Object
-
#initialize(file_path: nil) ⇒ ReadFile
constructor
A new instance of ReadFile.
- #input_schema ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(file_path: nil) ⇒ ReadFile
Returns a new instance of ReadFile.
12 13 14 |
# File 'lib/act_as_agent/tools/read_file.rb', line 12 def initialize(file_path: nil) @file_path = file_path end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
10 11 12 |
# File 'lib/act_as_agent/tools/read_file.rb', line 10 def file_path @file_path end |
Instance Method Details
#call(args = {}) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/act_as_agent/tools/read_file.rb', line 35 def call(args = {}) path = args.fetch("file_path", nil) return File.read(path) unless path.nil? || path.chomp == "" return File.read(file_path) unless file_path.nil? ERROR.new("Incorrect params have been given to list files tool") end |
#description ⇒ Object
20 21 22 |
# File 'lib/act_as_agent/tools/read_file.rb', line 20 def description "Read file by the given path" end |
#input_schema ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/act_as_agent/tools/read_file.rb', line 24 def input_schema { type: "object", properties: { file_path: { type: "string", description: "File path to read" } }, required: [] } end |
#name ⇒ Object
16 17 18 |
# File 'lib/act_as_agent/tools/read_file.rb', line 16 def name self.class.to_s.gsub("::", "__") end |