Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pal addin not working with chat_github (Copilot enabled thanks to GitHub Education pack) #79

Closed
lcolladotor opened this issue Jan 24, 2025 · 5 comments

Comments

@lcolladotor
Copy link

Hi,

Thanks for making pal! I was just testing it out and it seems that it doesn't work with chat_github as an option. I have GitHub Copilot thanks to my GitHub Education Pack (teacher) and have Copilot configured following https://docs.posit.co/ide/user/ide/guide/tools/copilot.html. This code below does work for me:

library("ellmer")
chat <- chat_github()
live_console(chat)
## Example 1: What is my name?
## Example 2: Who created R?
## Example 3: How many Bioconductor packages are there right now?
## 
## Exit with Q

The following doesn't work with pal. Note that I've also tried editing the options with my ~/.Rprofile file (restarting the R session).

library("pal")
options(
  .pal_fn = "chat_github"
)

## Using the pal addin, then selecting "cli" doesn't do anything
rlang::abort("`save_pred` can only be used if the initial results saved predictions.")

## Similarly with selecting "roxygen" with the 3 lines below.
foo <- function(hola) {
    print(hola)
}

However, .init_pal("roxygen") does work as shown below. So hmm, I'm not sure what's the issue when using the addin or how to provide info that could be useful for debugging this.

library("pal")
options(
  .pal_fn = "chat_github"
)
pal_roxygen <- .init_pal("roxygen")
#> Using model = "gpt-4o".
pal_roxygen$chat("foo <- function(hola) {
    print(hola)
}")
#> [1] "#' Foo\n#'\n#' @description\n#' A short description...\n#' \n#' @param hola A value to print.\n#'\n#' @returns \n#' No return value, called for side effects.\n#'\n#' @export"
packageVersion("pal")
#> [1] '0.0.3'
packageVersion("ellmer")
#> [1] '0.1.0'
options(width = 120)
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 Patched (2024-12-07 r87428)
#>  os       macOS Sonoma 14.5
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/New_York
#>  date     2025-01-24
#>  pandoc   3.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.0)
#>  coro          1.1.0   2024-11-05 [1] CRAN (R 4.4.1)
#>  curl          6.2.0   2025-01-23 [1] CRAN (R 4.4.2)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.1)
#>  ellmer        0.1.0   2025-01-09 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.3   2025-01-10 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.5   2024-10-30 [1] CRAN (R 4.4.1)
#>  gitcreds      0.1.2   2022-09-08 [1] CRAN (R 4.4.0)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#>  httr2         1.0.7   2024-11-26 [1] CRAN (R 4.4.1)
#>  jsonlite      1.8.9   2024-09-20 [1] CRAN (R 4.4.1)
#>  knitr         1.49    2024-11-08 [1] CRAN (R 4.4.1)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.0)
#>  pal         * 0.0.3   2025-01-24 [1] Github (simonpcouch/pal@ef63063)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.0)
#>  rappdirs      0.3.3   2021-01-31 [1] CRAN (R 4.4.0)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.0)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.0)
#>  rmarkdown     2.29    2024-11-04 [1] CRAN (R 4.4.1)
#>  rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.4.1)
#>  S7            0.2.0   2024-11-07 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.4.1)
#>  xfun          0.50    2025-01-07 [1] CRAN (R 4.4.1)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Created on 2025-01-24 with reprex v2.1.1

Thanks for your time and help!

Best,
Leo

lcolladotor added a commit to lcolladotor/rnaseq_LCG-UNAM_2025 that referenced this issue Jan 24, 2025
@simonpcouch
Copy link
Owner

Thanks for the thorough description @lcolladotor! This is super strange.

So far, I'm unable to reproduce with options(.pal_fn = "chat_github"). I was initially unconvinced that ellmer wasn't actually just grabbing the response from OpenAI but it worked fine with and without my OpenAI API key present.

To help me narrow this down:

  • What does "doesn't work" look like for you? Specifically, I'm interested in whether, after you select some code and select the roxygen pal, a) the selection is undone and your cursor moved to a new line atop the current selection but then nothing happens or b) the selection you had made is left unaltered (and nothing happens after choosing the pal).
  • At appears this is the case from your Session info, but this is in RStudio rather than Positron, right?
  • Do you see the failure both when GitHub Copilot is enabled in Global Options and not?

@lcolladotor
Copy link
Author

lcolladotor commented Feb 4, 2025

Hi Simon,

Here's a short Zoom meeting recording where I tried to provide answers to the questions you asked.

https://jh.zoom.us/rec/share/JM5Ohp8we-ts3pHPkSgAfxdyjuhUgBSl64c8L26rTYoFIilFDY1CArbdl5XoQDOQ.2Wo-lVy3Yf3J2xuK
Passcode: G92sZs&K

I could also upload the video to YouTube if you prefer to have a more permanent version of it (the above link will auto destroy in 6 months). I'm not sure that I can upload it to the GitHub issue itself (the video is currently rendering so I don't have the file at hand yet).

Not recorded on the video was a test where I edited my ~/.Rprofile to include

options(
  .pal_fn = "chat_github"
)

Here's the link to the repo with the code I ran in the video: https://github.com/lcolladotor/testcopilot/blob/devel/R/pal.R.

Best,
Leo

RStudio version details:

RStudio 2024.12.0+467 "Kousa Dogwood" Release (cf37a3e5488c937207f992226d255be71f5e3f41, 2024-12-11) for macOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.12.0+467 Chrome/126.0.6478.234 Electron/31.7.6 Safari/537.36, Quarto 1.4.550 (/Applications/quarto/bin/quarto)

@lcolladotor
Copy link
Author

Video finished rendering. Here's the AI summary:

Image

And here's the video on YouTube: https://youtu.be/kpKOOJIcSHU. Although the mp4 file was 19 MB, GitHub didn't allow me to upload it directly to the issue thread.

@simonpcouch
Copy link
Owner

Thanks for recording this!

Ah, I see! You'll need to press "Enter" after making a selection from the dropdown in order for that pane to disappear and for the prompt to be submitted to the model.

I'll leave this issue open as a note to add a "Press Enter to submit" note in the pane. :)

@lcolladotor
Copy link
Author

Ahh thanks Simon!! It did work when pressing enter. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants