Class: Rubyagents::FileWrite

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

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:, content:) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rubyagents/tools/file_write.rb', line 13

def call(path:, content:)
  expanded = File.expand_path(path)
  FileUtils.mkdir_p(File.dirname(expanded))
  File.write(expanded, content)
  "Successfully wrote #{content.length} bytes to #{expanded}"
rescue => e
  "Error writing #{path}: #{e.message}"
end