{"id":13642119,"url":"https://github.com/jcrodriguez1989/chatgpt","last_synced_at":"2025-05-15T12:02:28.210Z","repository":{"id":65315638,"uuid":"587350044","full_name":"jcrodriguez1989/chatgpt","owner":"jcrodriguez1989","description":"Interface to ChatGPT from R","archived":false,"fork":false,"pushed_at":"2025-01-31T13:08:21.000Z","size":228,"stargazers_count":325,"open_issues_count":4,"forks_count":36,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-14T19:59:32.672Z","etag":null,"topics":["assistant","chatgpt","gpt-3","gpt-4","hacktoberfest","llm","nlp","openai","r","rstats","rstats-package","rstatses","rstudio","rstudio-addin"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcrodriguez1989.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-10T14:49:49.000Z","updated_at":"2025-04-14T06:00:05.000Z","dependencies_parsed_at":"2023-11-09T11:49:05.100Z","dependency_job_id":"f46554d2-9a32-44db-9846-9ab4a3e559ca","html_url":"https://github.com/jcrodriguez1989/chatgpt","commit_stats":{"total_commits":61,"total_committers":7,"mean_commits":8.714285714285714,"dds":0.180327868852459,"last_synced_commit":"d22a39a539465b8799234fe5a3af29afb9d56503"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2Fchatgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2Fchatgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2Fchatgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2Fchatgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcrodriguez1989","download_url":"https://codeload.github.com/jcrodriguez1989/chatgpt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assistant","chatgpt","gpt-3","gpt-4","hacktoberfest","llm","nlp","openai","r","rstats","rstats-package","rstatses","rstudio","rstudio-addin"],"created_at":"2024-08-02T01:01:27.774Z","updated_at":"2025-05-15T12:02:28.162Z","avatar_url":"https://github.com/jcrodriguez1989.png","language":"R","funding_links":[],"categories":["Chatbots","Other Popular Interfaces to LLM Models in R","R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nlibrary(\"chatgpt\")\nSys.setenv(\"OPENAI_VERBOSE\" = FALSE)\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\n```\n\n# ChatGPT coding assistant for RStudio\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/chatgpt)](https://CRAN.R-project.org/package=chatgpt)\n[![R-CMD-check](https://github.com/jcrodriguez1989/chatgpt/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jcrodriguez1989/chatgpt/actions/workflows/R-CMD-check.yaml)\n[![CRAN downloads](https://cranlogs.r-pkg.org/badges/chatgpt)](https://cran.rstudio.com/web/packages/chatgpt/index.html)\n\u003c!-- badges: end --\u003e\n\n\u003ccenter\u003e\n    \u003cimg width=\"300\" height=\"400\" src=\"man/figures/chatgpt_meme.jpeg\"\u003e\n    \u003cp\u003eMeme by Programming Jokes I IT Humor \u0026 Memes\u003c/p\u003e\n\u003c/center\u003e\n\n## Installation\n\nInstall the current released version of `{chatgpt}` from \n[CRAN](https://cran.r-project.org/package=chatgpt):\n\n```{r eval = FALSE}\ninstall.packages(\"chatgpt\")\n```\n\nOr install the development version from [GitHub](https://github.com/jcrodriguez1989/chatgpt) with:\n\n```{r eval = FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"jcrodriguez1989/chatgpt\")\n```\n\n## Requirements\n\nYou need to setup your ChatGPT API key in R.\n\nFirst you will need to obtain your ChatGPT API key. You can create an API key by accessing [OpenAI API page](https://beta.openai.com/account/api-keys) -don't miss their article about [Best Practices for API Key Safety\n](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)-.\n\nThen you have to assign your API key for usage in R, this can be done just for the actual session, by doing:\n\n``` r\nSys.setenv(OPENAI_API_KEY = \"XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\")\n```\n\nOr you can do it persistent (session-wide), by assigning it in your `.Renviron` file. For it, execute `usethis::edit_r_environ()`, and in that file write a line at the end your API key as\n\n``` r\nOPENAI_API_KEY=XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n```\n\n## Features\n\nThe {chatgpt} R package provides a set of features to assist in R coding. \nCurrent existing addins:\n\n```{r, echo=FALSE, results='asis'}\naddins_info \u003c- readLines(\"inst/rstudio/addins.dcf\")\naddins_info \u003c- addins_info[grepl(\"^(Name: |Description: )\", addins_info)]\naddins_info \u003c- gsub(\"^(Name: |Description: )\", \"\", addins_info)\nindexes \u003c- seq_len(length(addins_info))\nindexes \u003c- indexes[indexes %% 2 == 1]\ncat(paste(\n  sapply(indexes, function(i) paste0(\" - **\", addins_info[[i]], \":** \", addins_info[[i + 1]])),\n  collapse = \"\\n\"\n))\n```\n\n**Note:** When no code is selected, it will use the whole file's code.\n\n## Common Errors\n\n#### You exceeded your current quota, please check your plan and billing details   \n\n```r\nError in gpt_get_completions: \n  list(message = \"You exceeded your current quota, please check your plan and billing details.\", type = \"insufficient_quota\", param = NULL, code = NULL)\n```\n\nTo fix this, you need to **provide a billing method** in OpenAI. More information can be found in this [article](https://help.openai.com/en/articles/6891831-error-code-429-you-exceeded-your-current-quota-please-check-your-plan-and-billing-details).\n\n## Code Examples\n\n```{r, echo=FALSE, results='asis'}\npkg_name \u003c- \"chatgpt\"\nexported_functions \u003c- setdiff(sort(getNamespaceExports(pkg_name)), \"reset_chat_session\")\nexamples_usage \u003c- sapply(exported_functions, function(exported_function) {\n  function_example \u003c- example(exported_function, pkg_name, character.only = TRUE, give.lines = TRUE)\n  function_example \u003c- function_example[grepl(\"^##D \", function_example)]\n  function_example \u003c- gsub(\"^##D \", \"\", function_example)\n  example_result \u003c- capture.output(eval(parse(text = function_example)))\n  example_result \u003c- gsub(\"`|'\", \"\", paste0(example_result, collapse = \"\\n\"))\n  paste0(\n    paste0(\"#### `\", exported_function, \"`\\n\\n``` r\\n\"),\n    paste0(\"\u003e \", function_example, \"\\n\"),\n    example_result,\n    \"\\n```\",\n    collapse = \"\\n\"\n  )\n})\ncat(paste0(\"\\n\", examples_usage, collapse = \"\\n\\n\"))\n```\n\n## Additional Parameters\n\n### Disable Console Messages\n\nIf you want {chatgpt} not to show messages in console, please set the environment variable `OPENAI_VERBOSE=FALSE`.\n\n### Addin Changes in Place\n\nIf you want {chatgpt} addins to take place in the editor -i.e., replace the selected code with the result of the addin execution- then you sould set the environment variable `OPENAI_ADDIN_REPLACE=TRUE`.\n\n### Change the language of ChatGPT responses\n\nTo change the language that ChatGPT responds in, the `OPENAI_RETURN_LANGUAGE` environment variable must be changed.\nE.g., \n\n```{r}\nSys.setenv(\"OPENAI_RETURN_LANGUAGE\" = \"Español\")\ncat(chatgpt::explain_code(\"for (i in 1:10) {\\n  print(i ** 2)\\n}\"))\n```\n\n### Use ChatGPT behind a proxy\n\nIn order to run ChatGPT queries behind a proxy, set the `OPENAI_PROXY` environment variable with a valid `IP:PORT` proxy.\nE.g., `Sys.setenv(\"OPENAI_PROXY\" = \"81.94.255.13:8080\")`.\n\n### Switch OPENAI's API URL\n\nTo replace the default OPENAI's API URL (`\"https://api.openai.com/v1\"`), you can set the `OPENAI_API_URL` environment variable with the URL you need to use.\nE.g., `Sys.setenv(\"OPENAI_API_URL\" = \"https://api.chatanywhere.com.cn\")`.\n\n### ChatGPT Model Tweaks\n\nChatGPT model parameters can be tweaked by using environment variables.\n\nThe following environment variables can be set to tweak the behavior, as documented in https://beta.openai.com/docs/api-reference/completions/create .\n\n* `OPENAI_MODEL`; defaults to `\"gpt-4o-mini\"`\n* `OPENAI_MAX_TOKENS`; defaults to `256`\n* `OPENAI_TEMPERATURE`; defaults to `1`\n* `OPENAI_TOP_P`; defaults to `1`\n* `OPENAI_FREQUENCY_PENALTY`; defaults to `0`\n* `OPENAI_PRESENCE_PENALTY`; defaults to `0`\n* `OPENAI_LOGPROBS`; defaults to `FALSE`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrodriguez1989%2Fchatgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcrodriguez1989%2Fchatgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrodriguez1989%2Fchatgpt/lists"}