Skip to contents

Tool: Write a text file

Usage

btw_tool_files_write_text_file(path, content, `_intent` = "")

Arguments

path

Path to the file to write. The path must be in the current working directory.

content

The text content to write to the file. This should be the complete content as the file will be overwritten.

_intent

An optional string describing the intent of the tool use. When the tool is used by an LLM, the model will use this argument to explain why it called the tool.

Value

Returns a message confirming the file was written.

Examples

withr::with_tempdir({
  btw_tool_files_write_text_file("example.txt", "Hello\nWorld!")
  readLines("example.txt")
})
#> [1] "Hello"  "World!"