Class: OmniAI::Tools::Disk::FileWriteTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/omniai/tools/disk/file_write_tool.rb

Overview

Examples:

tool = OmniAI::Tools::Disk::FileWriteTool.new(root: "./project")
tool.execute(path: "./README.md", text: "Hello World")

Instance Method Summary collapse

Methods inherited from BaseTool

#initialize

Constructor Details

This class inherits a constructor from OmniAI::Tools::Disk::BaseTool

Instance Method Details

#execute(path:, text:) ⇒ String

Parameters:

  • path (String)
  • text (String)

Returns:

  • (String)


21
22
23
24
25
26
27
# File 'lib/omniai/tools/disk/file_write_tool.rb', line 21

def execute(path:, text:)
  @logger.info("#{self.class.name}#execute path=#{path}")
  File.write(resolve!(path:), text)
rescue StandardError => e
  @logger.error("ERROR: #{e.message}")
  raise e
end