Skip to contents

These functions describe package documentation in plain text.

Usage

btw_tool_docs_package_help_topics(package_name, .intent = "")

btw_tool_docs_help_page(topic, package_name = "", .intent = "")

btw_tool_docs_available_vignettes(package_name, .intent = "")

btw_tool_docs_vignette(package_name, vignette = package_name, .intent = "")

Arguments

package_name

The name of the package as a string, e.g. "shiny".

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

topic

The topic_id or alias of the help page, e.g. "withProgress" or "incProgress". Find topic_ids or aliases using get_package_help().

vignette

The name (or index) of the vignette to retrieve. Defaults to the "intro" vignette to the package (by the same rules as pkgdown.)

Value

  • btw_tool_docs_package_help_topics() returns the topic_id, title, and aliases fields for every topic in a package's documentation as a json-formatted string.

  • btw_tool_docs_help_page() returns the help-page for a package topic as a string.

Examples

btw_tool_docs_package_help_topics("btw")
#> <btw::BtwToolResult>
#>  @ value  : chr [1:3] "```json" ...
#>  @ error  : NULL
#>  @ extra  :List of 1
#>  .. $ data: tibble [23 × 3] (S3: tbl_df/tbl/data.frame)
#>  ..  ..$ topic_id: chr [1:23] "btw" "btw-package" "btw_client" "btw_this" ...
#>  ..  ..$ title   : chr [1:23] "Plain-text descriptions of R objects" "btw: Describe R Stuff to Large Language Models" "Create a btw-enhanced ellmer chat client" "Describe something for use by an LLM" ...
#>  ..  ..$ aliases :List of 23
#>  ..  .. ..$ : 'AsIs' chr "btw"
#>  ..  .. ..$ : 'AsIs' chr "btw-package"
#>  ..  .. ..$ : 'AsIs' chr [1:2] "btw_client" "btw_app"
#>  ..  .. ..$ : 'AsIs' chr "btw_this"
#>  ..  .. ..$ : 'AsIs' chr "btw_this.character"
#>  ..  .. ..$ : 'AsIs' chr [1:2] "btw_this.data.frame" "btw_this.tbl"
#>  ..  .. ..$ : 'AsIs' chr "btw_this.environment"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_docs_package_news"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_env_describe_data_frame"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_env_describe_environment"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_files_list_files"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_files_read_text_file"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_files_write_text_file"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_ide_read_current_editor"
#>  ..  .. ..$ : 'AsIs' chr [1:5] "btw_tool_package_docs" "btw_tool_docs_package_help_topics" "btw_tool_docs_help_page" "btw_tool_docs_available_vignettes" ...
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_search_package_info"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_search_packages"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_session_check_package_installed"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_session_package_info"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_session_platform_info"
#>  ..  .. ..$ : 'AsIs' chr "btw_tool_web_read_url"
#>  ..  .. ..$ : 'AsIs' chr "btw_tools"
#>  ..  .. ..$ : 'AsIs' chr [1:3] "mcp" "btw_mcp_server" "btw_mcp_session"
#>  @ request: NULL

btw_tool_docs_help_page("btw", "btw")
#> <btw::BtwHelpPageToolResult>
#>  @ value  : chr [1:76] "## `help(package = \"btw\", \"btw\")`" "" ...
#>  @ error  : NULL
#>  @ extra  :List of 3
#>  .. $ help_text: chr [1:75] "" "### Plain-text descriptions of R objects" "" "#### Description" ...
#>  .. $ topic    : chr "btw"
#>  .. $ package  : chr "btw"
#>  @ request: NULL

# show the TOC of vignettes in the dplyr package
btw_tool_docs_available_vignettes("dplyr")
#> <btw::BtwToolResult>
#>  @ value  : chr [1:11] "[" ...
#>  @ error  : NULL
#>  @ extra  :List of 1
#>  .. $ data:'data.frame':	9 obs. of  2 variables:
#>  ..  ..$ vignette: chr [1:9] "colwise" "grouping" "dplyr" "programming" ...
#>  ..  ..$ title   : chr [1:9] "Column-wise operations" "Grouped data" "Introduction to dplyr" "Programming with dplyr" ...
#>  @ request: NULL

# returns a whole bunch of output and relies on
# dplyr to have the mentioned vignettes available
if (FALSE) { # \dontrun{
# grab the intro vignette
btw_tool_docs_vignette("dplyr")

# grab the programming vignette specifically
btw_tool_docs_vignette("dplyr", "programming")
} # }