Learn R Programming

btw (version 1.0.0)

btw_tool_ide_read_current_editor: Tool: Read current file

Description

Reads the current file using the rstudioapi, which works in RStudio, Positron and VS Code (with the vscode-r extension).

Usage

btw_tool_ide_read_current_editor(
  selection = TRUE,
  consent = FALSE,
  `_intent` = ""
)

Value

Returns the contents of the current editor.

Arguments

selection

Should only the selected text be included? If no text is selected, the full file contents are returned.

consent

Boolean indicating whether the user has consented to reading the current file. The tool definition includes language to induce LLMs to confirm with the user before calling the tool. Not all models will follow these instructions. Users can also include the string @current_file to induce the tool.

_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.

See Also

Other Tools: btw_tool_docs_package_news(), btw_tool_env_describe_data_frame(), btw_tool_env_describe_environment(), btw_tool_files_code_search(), btw_tool_files_list_files(), btw_tool_files_read_text_file(), btw_tool_files_write_text_file(), btw_tool_package_docs, btw_tool_search_packages(), btw_tool_session_package_info(), btw_tool_session_platform_info(), btw_tool_web_read_url(), btw_tools()

Examples

Run this code
if (FALSE) { # rstudioapi::hasFun("getSourceEditorContext")
btw_tool_ide_read_current_editor(consent = TRUE)
}

Run the code above in your browser using DataLab