Positron IDE accessing GitHub Copilot via {chattr} R Package (Public Beta)

Опубликовано: 08 Апрель 2025
на канале: TheCoatlessProfessor
1,874
33

Timeline ---

00:00 Greetings and introduction to Positron IDE for data science and its ability to use a code assist agent like GitHub Copilot.
00:15 Mentioning that the demonstration will focus on R, as there's no known official extension for GitHub Copilot in Positron.
00:32 Checking the Extensions tab in Positron and noting the absence of a GitHub Copilot extension.
00:45 Highlighting the availability of other generic code assist extensions.
01:00 Switch into the R interpreter
01:10 Demonstrating the installation of the remotes package in an R session.
01:18 Installing the 'chattr' package from GitHub using the remotes package from Posit's mlverse organization.
01:40 Running the chattr::chatr_app() in Positron, allowing the use of GitHub Copilot Chat or chat completions with GPT-4o.
02:00 Opting to use GitHub Copilot Chat and opening a Shiny application for interaction.
02:13 Demonstrating a chat with GitHub Copilot Chat, requesting an R function that counts down from 10 to 1 and prints "blast off".
02:37 Viewing the generated function on the right-hand side of the Shiny app.
02:51 Copying the generated function and pasting it into a new R script in Positron.
03:04 Discussing the downside of using a Shiny app as it overwrites the main console, requiring stopping the Shiny app to run the script.
03:25 Running the R script in Positron and executing the 'blastoff' function.
03:41 Displaying the output of the 'blastoff' function generated by the LLM model.
03:50 Concluding remarks on using GitHub Copilot in Positron and closing the video.


Summary ---

In this video, we use the Positron IDE (Public Beta) with GitHub Copilot through the {chattr} R package.

Unfortunately, Positron does not have an official GitHub Copilot plugin nor is it likely to get one due to licensing, c.f. https://github.com/posit-dev/positron...

Thus, we need to find an alternative way to access GitHub Copilot. One avenue is to use the {chattr} R package created by Posit's mlverse team for an AI-augmented coding session. The {chattr} package includes a Shiny application that can be launched and viewed inside of the Positron browser.

To have both GitHub Copilot and GPT-4o available, we'll need to use the development back of {chattr} on GitHub. Note, that the CRAN version will only show GitHub Copilot as being available.

As a result, we'll first need to install the `remotes` package to obtain a package from GitHub using:

install.packages("remotes")

Then, we need to install the latest development version of {chattr} using:

remotes::install_github("mlverse/chattr")

Next, we need to initiate a chat session using:

chattr::chattr_app()

Specify 1 for Copilot and 2 for GPT-4o.

We can then submit queries on the right-hand side.

However, before running output from the Queries, we must stop the chat otherwise the R console will not be available for us to run code.

Links ---

GitHub Copilot:
https://github.com/features/copilot

{chattr} R package:
https://github.com/mlverse/chattr

Code scripts:
https://github.com/coatless-videos/po...

Positron IDE ---

Positron can be obtained from:

https://github.com/posit-dev/positron

This was demonstrated on:

Positron Version: 2024.06.1 (Universal) build 27
Code - OSS Version: 1.90.0
Commit: a893e5b282612ccb2200102957ac38d3c14e5196
Date: 2024-06-26T02:08:06.673Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

#positron #posit #rstudio #rstats #githubcopilot #chattr #genai