Pals are persistent, ergonomic LLM assistants designed to help you
complete repetitive, hard-to-automate tasks quickly. After selecting
some code, press the keyboard shortcut you’ve chosen to trigger the pal
addin (we suggest Ctrl+Cmd+P
), select the pal, and watch your code be
rewritten.
Much of the documentation in this package is aspirational and its interface is likely to change rapidly.
You can install pal like so:
pak::pak("simonpcouch/pal")
Then, ensure that you have an
ANTHROPIC_API_KEY
environment
variable set, and you’re ready to go. If you’d like to use an LLM other
than Anthropic’s Claude 3.5 Sonnet—like OpenAI’s ChatGPT—to power the
pal, see the Getting started with
pal vignette.
Pals are created automatically when users interact with the pal addin. Just highlight some code, open the addin, begin typing the “role” of your pal and press “Return”, and watch your code be rewritten:
As-is, the package provides ergonomic LLM assistants for R package development:
"cli"
: Convert to cli"testthat"
: Convert to testthat 3"roxygen"
: Document functions with roxygen
That said, all you need to create your own pal is a markdown file with some instructions on how you’d like it to work.
The cost of using pals depends on 1) the length of the underlying prompt for a given pal and 2) the cost per token of the chosen model. Using the cli pal with Anthropic’s Claude Sonnet 3.5, for example, costs something like $15 per 1,000 code refactorings, while using the testthat pal with OpenAI’s GPT 4o-mini would cost something like $1 per 1,000 refactorings. Pals using a locally-served LLM are “free” (in the usual sense of code execution, ignoring the cost of increased battery usage).