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