Method: Langchain::Tool::FileSystem#write_to_file

Defined in:
lib/langchain/tool/file_system.rb

#write_to_file(file_path:, content:) ⇒ Object



38
39
40
41
42
43
# File 'lib/langchain/tool/file_system.rb', line 38

def write_to_file(file_path:, content:)
  File.write(file_path, content)
  tool_response(content: "File written successfully")
rescue Errno::EACCES
  tool_response(content: "Permission denied: #{file_path}")
end