Movatterモバイル変換


[0]ホーム

URL:


btwbtw website

A complete toolkit for connecting R and LLMs

CRAN statusR-universe versionR-CMD-checkCodecov test coverage

Overview

btw helps R users work with Large Language Models, whether you’repasting context into ChatGPT, chatting with an AI assistant in your IDE,or building LLM-powered applications.

The challenge: LLMs need context about your R environment to behelpful—your data structures, the packages you’re using, relevantdocumentation.

btw provides a flexible toolkit that works across differentworkflows:

Quick Start

Copy-paste workflow

Usebtw() to gather context from your R session and copyit to your clipboard:

library(btw)# Describe a data framebtw(mtcars)# Include package or function documentationbtw("{dplyr}", ?dplyr::across)# Combine multiple pieces of contextbtw(mtcars,"{dplyr}","How do I calculate the mean mpg by cylinder?")

The context is copied to your clipboard, ready to paste into ChatGPT,Claude, or any LLM chat interface.

Interactive chat in your IDE

Launch a chat interface withbtw_app():

btw_app()

Screenshot of btw_app() in action. In the sidebar, there is a list of tools that can be toggled on and off, and in the main panel a chat interface. In the chat we can see several tool calls have been made to read files in the current project.

For persistent project context, create abtw.md filewithuse_btw_md(). This creates a project-specificconfiguration file where you can define your preferred LLM provider,model, and custom instructions that apply to all conversations in yourproject.

Building with btw

btw superchargesellmer!Usebtw_client() for a pre-configured chat client, the sameclient used bybtw_app().

# Uses provider, model, tools and instructions from btw.mdchat<-btw_client()chat$chat("Help me write documentation for...")

Or usebtw_tools() to get a list of tools you canregister with any ellmer chat client.

library(ellmer)chat<-chat_anthropic()# or chat_openai(), chat_ollama(), etc.chat$register_tools(btw_tools())chat$chat("What data frames are in my environment?")

Pick and choose which tools you use with friendly group names

# Only provide documentation and file toolschat$register_tools(btw_tools(c("docs","files")))

or expose btw tools to external coding agents via theModel Context Protocolusingmcptools.

# Run as a background process or in a separate R sessionbtw_mcp_server()

You canconfigure theMCP server in Claude Desktop, Continue, or other MCP-compatibletools to give them access to your R environment.

Installation

You can install btw from CRAN:

install.packages("btw")

To install the latest development version, you can install fromposit-dev.r-universe.dev:

# install.packages("pak")pak::repo_add("https://posit-dev.r-universe.dev")pak::pak("btw")

Or you can install the development version fromGitHub:

# install.packages("pak")pak::pak("posit-dev/btw")

Learn More

For questions or issues, pleaseopen an issue onGitHub.


[8]ページ先頭

©2009-2025 Movatter.jp