Skip to contents

The btw_tools() function provides a list of tools that can be registered with an ellmer chat via chat$set_tools() that allow the chat to interface with your computational environment. Chats returned by this function have access to the tools:

NameGroupDescription
btw_tool_docs_available_vignettesdocsList available vignettes for an R package.
btw_tool_docs_help_pagedocsGet help page from package.
btw_tool_docs_package_help_topicsdocsGet available help topics for an R package.
btw_tool_docs_package_newsdocsRead the release notes (NEWS) for a package.
btw_tool_docs_vignettedocsGet a package vignette in plain text.
btw_tool_env_describe_data_frameenvShow the data frame or table or get information about the structure of a data frame or table.
btw_tool_env_describe_environmentenvList and describe items in an environment.
btw_tool_files_list_filesfilesList files or directories in the project.
btw_tool_files_read_text_filefilesRead an entire text file.
btw_tool_files_write_text_filefilesWrite content to a text file.
btw_tool_ide_read_current_editorideRead the contents of the editor that is currently open in the user's IDE.
btw_tool_search_package_infosearchDescribe a CRAN package.
btw_tool_search_packagessearchSearch for an R package on CRAN.
btw_tool_session_check_package_installedsessionCheck if a package is installed in the current session.
btw_tool_session_package_infosessionVerify that a specific package is installed, or find out which packages are in use in the current session.
btw_tool_session_platform_infosessionDescribes the R version, operating system, language and locale settings for the user's system.
btw_tool_web_read_urlwebRead a web page and convert it to Markdown format.

Usage

btw_tools(...)

Arguments

...

Optional names of tools or tool groups to include when registering tools. By default all btw tools are included. For example, use "docs" to include only the documentation related tools, or "env", "docs", "session" for the collection of environment, documentation and session tools, and so on.

The names provided can be:

  1. The name of a tool, such as "btw_tool_env_describe_data_frame".

  2. The name of a tool group, such as "env", which will include all tools in that group.

  3. The tool name without the btw_tool_ prefix, such as "env_describe_data_frame".

Value

Registers the tools with chat, updating the chat object in place. The chat input is returned invisibly.

Examples

# requires an ANTHROPIC_API_KEY
if (FALSE) { # \dontrun{
ch <- ellmer::chat_anthropic()

# register all of the available tools
ch$set_tools(btw_tools())

# or register only the tools related to fetching documentation
ch$set_tools(btw_tools("docs"))

# ensure that the current tools persist
ch$set_tools(c(ch$get_tools(), btw_tools()))
} # }