Class: LLM::Tool::WriteFile

Inherits:
LLM::Tool show all
Defined in:
lib/llm/tools/write_file.rb

Overview

The LLM::Tool::WriteFile class implements a tool that can write a given string to a given file path.

Instance Method Summary collapse

Methods inherited from LLM::Tool

a2a, a2a?, #a2a?, clear_registry!, description, find_by_name!, function, #function, inherited, mcp, mcp?, #mcp?, name, #on_cancel, #on_interrupt, params, register, registry, skill?, #skill?, unregister

Methods included from Param

#param, #required

Methods included from Function::Registry

#clear_registry!, extended, #find_by_name, #lock, #register, #registry, #registry_key, #tool_name, #unregister

Instance Method Details

#call(path:, content:) ⇒ Hash

Parameters:

  • path (String)
  • content (String)

Returns:

  • (Hash)


19
20
21
22
# File 'lib/llm/tools/write_file.rb', line 19

def call(path:, content:)
  File.open(path, "w") { _1.write(content) }
  {ok: true}
end