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

Shiny Chat app crashes when clicking on options button #181

Closed
wzamaral opened this issue Mar 1, 2024 · 14 comments
Closed

Shiny Chat app crashes when clicking on options button #181

wzamaral opened this issue Mar 1, 2024 · 14 comments

Comments

@wzamaral
Copy link

wzamaral commented Mar 1, 2024

I wanted to switch models, but when I click on the options button, the Viewer window shows the options form for a fraction of a second and the Viwer window goes black. It seems like the Shiny Chat app crashes. In Background Jobs, it shows:

Warning: Error in purrr::map_chr: ℹ In index: 1.
Caused by error:
! Result must be length 1, not 0.
80:
79: signalCondition
78: signal_abort
77: rlang::abort
76: cli::cli_abort
75: h
74: .handleSimpleError
73: call_with_cleanup
70: map_
69: purrr::map_chr
68: %>%
67: get_available_models
66:
50: models
48: observe
47:
4: shiny::runApp
3: eval
2: eval
1: .rs.sourceWithProgress
Deleting chat history from this session.

R/RStudio/Package, all up-to-date as of Mar 1 2024. This is a new installation of GPTStudio. Works fine with OpenAI API.
Thanks.

@calderonsamuel
Copy link
Collaborator

Thank for your report. Please try the development version and let us know if the problem persists:

# install.packages("pak")
pak::pak("MichelNivard/gptstudio")

If so, please paste the output of running sessioninfo::session_info(pkgs = "gptstudio")

@JuliusGr01
Copy link

JuliusGr01 commented Mar 6, 2024

Hi! I am having the same issue.
Here my output from running session_info::session_info(pkgs = "gptstudio"):

`> gptstudio:::gptstudio_chat()
✔ gptstudio initialized as background job in RStudio
ℹ Showing app in 'Viewer' pane
ℹ Run rstudioapi::viewer("http://127.0.0.1:7877") to see it'

> sessioninfo::session_info(pkgs = "gptstudio")
─ Session info ───────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.2 (2023-10-31)
 os       macOS Sonoma 14.1.2
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Berlin
 date     2024-03-06
 rstudio  2023.12.1+402 Ocean Storm (desktop)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────────
 package     * version    date (UTC) lib source
 askpass       1.2.0      2023-09-03 [1] CRAN (R 4.3.0)
 assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.3.0)
 base64enc     0.1-3      2015-07-28 [1] CRAN (R 4.3.0)
 bslib         0.6.0      2023-11-21 [1] CRAN (R 4.3.1)
 cachem        1.0.8      2023-05-01 [1] CRAN (R 4.3.0)
 cli           3.6.1      2023-03-23 [1] CRAN (R 4.3.0)
 colorspace    2.1-0      2023-01-23 [1] CRAN (R 4.3.0)
 commonmark    1.9.0      2023-03-17 [1] CRAN (R 4.3.0)
 crayon        1.5.2      2022-09-29 [1] CRAN (R 4.3.0)
 curl          5.1.0      2023-10-02 [1] CRAN (R 4.3.1)
 digest        0.6.33     2023-07-07 [1] CRAN (R 4.3.0)
 ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.3.0)
 evaluate      0.23       2023-11-01 [1] CRAN (R 4.3.1)
 fansi         1.0.5      2023-10-08 [1] CRAN (R 4.3.1)
 fastmap       1.1.1      2023-02-24 [1] CRAN (R 4.3.0)
 fontawesome   0.5.2      2023-08-19 [1] CRAN (R 4.3.0)
 fs            1.6.3      2023-07-20 [1] CRAN (R 4.3.0)
 glue          1.6.2      2022-02-24 [1] CRAN (R 4.3.0)
 gptstudio     0.3.1.9004 2024-03-06 [1] Github (MichelNivard/gptstudio@30539f0)
 highr         0.10       2022-12-22 [1] CRAN (R 4.3.0)
 htmltools     0.5.7      2023-11-03 [1] CRAN (R 4.3.1)
 htmlwidgets   1.6.4      2023-12-06 [1] CRAN (R 4.3.1)
 httpuv        1.6.14     2024-01-26 [1] CRAN (R 4.3.1)
 httr          1.4.7      2023-08-15 [1] CRAN (R 4.3.0)
 httr2         1.0.0      2023-11-14 [1] CRAN (R 4.3.1)
 ids           1.0.1      2017-05-31 [1] CRAN (R 4.3.0)
 jquerylib     0.1.4      2021-04-26 [1] CRAN (R 4.3.0)
 jsonlite      1.8.8      2023-12-04 [1] CRAN (R 4.3.1)
 knitr         1.45       2023-10-30 [1] CRAN (R 4.3.1)
 later         1.3.2      2023-12-06 [1] CRAN (R 4.3.1)
 lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.3.1)
 magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.3.0)
 memoise       2.0.1      2021-11-26 [1] CRAN (R 4.3.0)
 mime          0.12       2021-09-28 [1] CRAN (R 4.3.0)
 openssl       2.1.1      2023-09-25 [1] CRAN (R 4.3.1)
 pillar        1.9.0      2023-03-22 [1] CRAN (R 4.3.0)
 pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.3.0)
 promises      1.2.1      2023-08-10 [1] CRAN (R 4.3.0)
 purrr         1.0.2      2023-08-10 [1] CRAN (R 4.3.0)
 R6            2.5.1      2021-08-19 [1] CRAN (R 4.3.0)
 rappdirs      0.3.3      2021-01-31 [1] CRAN (R 4.3.0)
 Rcpp          1.0.11     2023-07-06 [1] CRAN (R 4.3.0)
 rlang         1.1.2      2023-11-04 [1] CRAN (R 4.3.1)
 rmarkdown     2.25       2023-09-18 [1] CRAN (R 4.3.2)
 rstudioapi    0.15.0     2023-07-07 [1] CRAN (R 4.3.0)
 rvest         1.0.3      2022-08-19 [1] CRAN (R 4.3.0)
 sass          0.4.7      2023-07-15 [1] CRAN (R 4.3.0)
 selectr       0.4-2      2019-11-20 [1] CRAN (R 4.3.0)
 shiny         1.8.0      2023-11-17 [1] CRAN (R 4.3.1)
 shiny.i18n    0.3.0      2023-01-16 [1] CRAN (R 4.3.0)
 sourcetools   0.1.7-1    2023-02-01 [1] CRAN (R 4.3.0)
 SSEparser     0.1.0      2023-12-14 [1] CRAN (R 4.3.1)
 stringi       1.8.2      2023-11-23 [1] CRAN (R 4.3.1)
 stringr       1.5.1      2023-11-14 [1] CRAN (R 4.3.1)
 sys           3.4.2      2023-05-23 [1] CRAN (R 4.3.0)
 tibble        3.2.1      2023-03-20 [1] CRAN (R 4.3.0)
 tinytex       0.49       2023-11-22 [1] CRAN (R 4.3.1)
 utf8          1.2.4      2023-10-22 [1] CRAN (R 4.3.1)
 uuid          1.1-1      2023-08-17 [1] CRAN (R 4.3.0)
 vctrs         0.6.4      2023-10-12 [1] CRAN (R 4.3.1)
 waiter        0.2.5      2022-01-03 [1] CRAN (R 4.3.0)
 withr         2.5.2      2023-10-30 [1] CRAN (R 4.3.1)
 xfun          0.41       2023-11-01 [1] CRAN (R 4.3.1)
 xml2          1.3.5      2023-07-06 [1] CRAN (R 4.3.0)
 xtable        1.8-4      2019-04-21 [1] CRAN (R 4.3.0)
 yaml          2.3.7      2023-01-23 [1] CRAN (R 4.3.0)

 [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

Thank you for any feedback and help!

@JuliusGr01
Copy link

Addition to above:
When running the same code (using development version) in Posit Cloud I get a different error message. There, after calling the command gptstudio:::gptstudio_chat() Viewer shows "Connection refused" (again, the Sys.getenv("OPENAI_API_KEY") returns the right key and my account is setup including valid payment info).
Bildschirmfoto 2024-03-06 um 15 44 31

@calderonsamuel
Copy link
Collaborator

Thank you @JuliusGr01 , these reports are extremely valuable to us!

For the crash when clicking the settings button, please try re-installing the development version (I see that @JamesHWade has been doing some updates). Nonetheless, we should have a get_available_models_*service*() or something similar for easier debugging in the future.

For the "connection refused" error please go to #179 and paste the output of session_info::session_info(pkgs = "gptstudio"). We were tracking this issue there and I assumed we already fixed it. If we confirm that the problem persists we should reopen the issue.

@JuliusGr01
Copy link

JuliusGr01 commented Mar 6, 2024

Thank you for the quick reply @calderonsamuel !
I have re-installed the development version just now and the problem persists for me (just for clarity: This problem is appearing the RStudio Desktop version (see attached screenshot). This appears after trying to "send" the prompt in the Viewer mirror.
Bildschirmfoto 2024-03-06 um 16 14 41

@kyleGrealis
Copy link

kyleGrealis commented Mar 6, 2024

Same issue as others here. I just did a fresh install via pak on Windows. I tried to use the OpenAI and Google AI tools, but both crashed on me when entering my first prompt.
Screenshot 2024-03-06 140416

@calderonsamuel
Copy link
Collaborator

While working in another project I realized that OpenAI made changes in its billing system. Now you need to "buy" some credits in their billing platform for the requests to work as expected. You can configure auto-recharge.

Please let us know it that solves this issue

@JuliusGr01
Copy link

@calderonsamuel Thanks! That dissolved the main problem of at least being able to get the basic/setup right.
However the problem that the shiny app crashes when clicking on options button persists, at least for me.

@kyleGrealis
Copy link

While working in another project I realized that OpenAI made changes in its billing system. Now you need to "buy" some credits in their billing platform for the requests to work as expected. You can configure auto-recharge.

Please let us know it that solves this issue

So then what's necessary to make it work with Gemini? I have a Google API key and have the same issue where the app crashes when attempting to change the options?

@calderonsamuel
Copy link
Collaborator

Thank you @JuliusGr01 and @kyleGrealis . It is clear to me now that this problem isn't related to just OpenAI. I'll dig into this later in the day. I'm not sure that I'll have the final fix but at least it will be easier to debug

@calderonsamuel
Copy link
Collaborator

There is a draft PR for this issue. Please install it with:

# install.packages("pak")
pak::pak("MichelNivard/gptstudio#190")

I wasn't able to reproduce the bug on any of my systems, so I don't think the issue is solved yet, but running this version will provide better tracing of the error. We are counting on you to solve this 🙏

@yujuanGG
Copy link

yujuanGG commented Mar 30, 2024

Hi! I'm able to reproduce the error using posit cloud. I created a new project and typed in the below code line by line. Thanks for this amazing package and hope this helps.

# install pak
install.packages("pak")

# install usethis
pak::pak("usethis")

# install gptstudio
pak::pak("gptstudio")

# set api key
usethis::edit_r_environ()

# relaunch project and test api key is set
Sys.getenv("OPENAI_API_KEY")

# launch gptstudio
# crash when clicking setup

@calderonsamuel
Copy link
Collaborator

Thank you @yujuanGG ! I was able to reproduce the bug with your code.

The solution is to install the development version of the package with pak::pak("MichelNivard/gptstudio"). This will install from the main branch of this repo, which is currently the most updated version. The "options" button is now placed in a sidebar panel and no longer stops the app when clicked. You might, however, get the "connection refused" error (in linux platforms, tracked in #179 ).

Since installing the development version fixes the issue in this thread, we will close it in a week unless someone can provide another way to reproduce the bug

@calderonsamuel
Copy link
Collaborator

Closing for not having additional info

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

5 participants