jbgruber / askgpt Goto Github PK
View Code? Open in Web Editor NEWA chat interface build on top of OpenAI's API endpoints
License: GNU General Public License v3.0
A chat interface build on top of OpenAI's API endpoints
License: GNU General Public License v3.0
Hi,
if I run the command:
askgpt("What is an R function?")
I get the following error messages:
Error:is thinking ⠇
! ! in callr subprocess.
Caused by error in resp_abort(resp, error_body(req, resp))
:
! HTTP 401 Unauthorized.
Run rlang::last_error()
to see where the error occurred.
✖ GPT is thinking ⠇ [1.6s]
I partly understand the problem but I do not know how to solve it in R. Btw I have full administrative rights on the PC and a working internet connection. Using ChatGPT in the explorer works fine as well.
Many thanks in advance!
Jörg
remotes::install_github("JBGruber/askgpt")
#rappdirs::user_cache_dir("askgpt")
#login(force_refresh = TRUE)
library(askgpt)
askgpt("Can you explain how functions work in R?")
Error:is thinking
! ! in callr subprocess.
Caused by error:
! Timeout was reached: [api.openai.com] Connection timeout after 10010 ms
Backtrace:
I got an error when I try to use askgpt:
library(askgpt)
log_init()
askgpt("what is an R function")
Error:is thinking ⠦
! ! in callr subprocess.
Caused by error in resp_abort(resp, error_body(req, resp))
:
! HTTP 429 Too Many Requests.
Run rlang::last_trace()
to see where the error occurred.
✖ GPT is thinking ⠦ [3.1s]
Running askgpt()
with the default arguments does not output anything to the screen:
> askgpt("Tell me about the askgpt R package")
✔ GPT is thinking ⠧ [17.5s]
>
However the answer is available using response_history()
:
> response_history()[1] |> cat()
Askgpt is an R package that provides an easy-to-use interface for OpenAI's GPT-3 API. GPT-3 (Generative Pre-trained Transformer 3) is a powerful language generation model developed by OpenAI, which can be used to generate human-like text in a wide variety of formats.
The askgpt R package allows users to easily generate text using GPT-3 from within the R environment, making it easy to incorporate natural language generation into R-based projects. The package provides an R wrapper around the GPT-3 API, which allows users to access the full range of GPT-3 functions, including text completion, text classification, and text translation.
To use askgpt, users must first sign up for an OpenAI API key and create an account with OpenAI. Once they have an account, they can install the askgpt package in R using the R console or Rstudio, and they can begin generating text using the GPT-3 API by providing an API key and a text prompt. The package also provides functions for fine-tuning the GPT-3 model, controlling the output length and format, and filtering the output to remove unwanted content.
The askgpt R package is a powerful tool for natural language generation and can be used in a wide variety of applications, including data analysis, machine learning, and text mining. It provides an intuitive and user-friendly interface for accessing the GPT-3 API, making it easy for anyone to start generating high-quality human-like text in R.
If there's any missing step in the configuration, I don't know what it is.
> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/Warsaw
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] askgpt_0.1.1
loaded via a namespace (and not attached):
[1] jsonlite_1.8.4 dplyr_1.1.2 compiler_4.3.0 tidyselect_1.2.0
[5] reprex_2.0.2 clipr_0.8.0 assertthat_0.2.1 callr_3.7.3
[9] yaml_2.3.7 fastmap_1.1.1 R6_2.5.1 generics_0.1.3
[13] curl_5.0.0 knitr_1.43 httr2_0.2.3 tibble_3.2.1
[17] openssl_2.0.6 R.cache_0.16.0 pillar_1.9.0 R.utils_2.12.2
[21] rlang_1.1.1 utf8_1.2.3 xfun_0.39 fs_1.6.2
[25] cli_3.6.1 withr_2.5.0 magrittr_2.0.3 ps_1.7.5
[29] digest_0.6.31 processx_3.8.1 rstudioapi_0.14 keyring_1.3.1
[33] rappdirs_0.3.3 askpass_1.1 lifecycle_1.0.3 R.methodsS3_1.8.2
[37] R.oo_1.25.0 vctrs_0.6.2 evaluate_0.21 glue_1.6.2
[41] styler_1.10.0 sessioninfo_1.2.2 fansi_1.0.4 rmarkdown_2.22
[45] purrr_1.0.1 htmltools_0.5.5 tools_4.3.0 pkgconfig_2.0.3
Getting the following output:
askgpt::annotate_code()
✔ GPT is thinking ⠧ [9.2s]
Warning message:
In file(loc, "ab") :
file("") only supports open = "w+" and open = "w+b": using the former
I am running on rstudio server
I moved the option to stream a response to a fork since it is broken for the chat API and does not really do anything nice for the completions API. Originally, it looked like streaming the response would create a similar 'typing' effect like on the ChatGPT site. But once the API starts streaming, it just sends the whole reply very quickly. I (or someone who feels like it) could fix the feature at some point, but I think it makes more sense to just remove it.
If code is returned in a R Markdown syntax, the underlying cli::cli_inform(c(trimws(out)))
evaluates it, since it is similar to glue
notation.
Example:
out <- "As an R tutor, I believe that it's important for you to learn and practice coding on your own. Therefore, I'll guide you through the process of writing a for loop to read in CSV files:\n\n1. Set your working directory to the folder containing the CSV files using the `setwd()` function. For example, `setwd(\"~/Documents/csv_folder\")`.\n\n2. Use the `list.files()` function to get a list of all the CSV files in the folder. For example, `csv_files <- list.files(path = \".\", pattern = \".csv\")`.\n\n3. Use a for loop to iterate over the files in the `csv_files` vector. For example:\n\n```\nfor (i in seq_along(csv_files)) {\n # Read in the CSV file\n csv_data <- read.csv(csv_files[i])\n \n # Do something with the data, if desired\n ...\n}\n```\n\nIn this code, `seq_along()` is used to create a sequence of numbers from 1 to the length of the `csv_files` vector. The for loop iterates over these numbers and uses them to index into the `csv_files` vector. The `read.csv()` function is then used to read in each file one at a time.\n\nNote that this is just one possible approach to reading in CSV files using a for loop, and there are many variations and options you could use depending on your specific situation. As an R tutor, I encourage you to experiment with different approaches and think critically about which methods are most appropriate for your tasks."
cli::cli_inform(c(trimws(out)))
#> Error in "lapply(text, glue_cmd, .envir = .envir)": ! Could not evaluate cli `{}` expression: ` # Read in the CS…`.
#> Caused by error in `read.table(file = file, header = header, sep = sep, quote = quote, …`:
#> ! object 'csv_files' not found
Created on 2023-03-15 with reprex v2.0.2
Everything in this answer between {
and }
is evaluated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.