Class: Rubyagents::FileRead

Inherits:
Tool
  • Object
show all
Defined in:
lib/rubyagents/tools/file_read.rb

Constant Summary collapse

MAX_CHARS =
50_000

Instance Method Summary collapse

Methods inherited from Tool

description, inherited, input, inputs, output_type, to_prompt, to_schema, tool_name

Instance Method Details

#call(path:) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rubyagents/tools/file_read.rb', line 12

def call(path:)
  expanded = File.expand_path(path)
  content = File.read(expanded)
  content.length > MAX_CHARS ? content[0, MAX_CHARS] : content
rescue => e
  "Error reading #{path}: #{e.message}"
end