Skip to contents

Tool: Read a file

Usage

btw_tool_files_read_text_file(path, max_lines = 1000, .intent = "")

Arguments

path

Path to a file for which to get information. The path must be in the current working directory.

max_lines

Number of lines to include. Defaults to 1,000 lines.

.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 character vector of lines from the file.

Examples

withr::with_tempdir({
  write.csv(mtcars, "mtcars.csv")

  btw_tool_files_read_text_file("mtcars.csv", max_lines = 5)
})
#> <btw::BtwTextFileToolResult>
#>  @ value  : chr [1:7] "```csv" ...
#>  @ error  : NULL
#>  @ extra  :List of 1
#>  .. $ path: 'fs_path' chr "mtcars.csv"
#>  @ request: NULL