forked from MichelNivard/gptstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
122 lines (74 loc) · 5.78 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# gptstudio <img src="man/figures/logo.png" align="right" height="98"/>
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental) [](https://CRAN.R-project.org/package=GPTstudio) [](https://app.codecov.io/gh/MichelNivard/gptstudio?branch=main) [](https://github.com/MichelNivard/gptstudio/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of gptstudio is for R programmers to easily incorporate use of large language models (LLMs) into their project workflows. These models appear to be a step change in our use of text for knowledge work, but you should carefully consider ethical implications of using these models. Ethics of LLMs (also called [Foundation Models](https://arxiv.org/abs/2108.07258)) is an area of very active discussion.
For further addins, tailored for R developers, also see the sister package: [gpttools](https://jameshwade.github.io/gpttools/)
## Install the addins from this package:
```{r}
#| eval: false
require(devtools)
install_github("MichelNivard/gptstudio")
```
## Privacy Notice
These functions work by taking the text or code you have highlighted/selected with the cursor, or your prompt if you use one of the built-in apps, and send these to OpenAI as part of a prompt; they fall under their privacy notice/rules/exceptions you agreed to with OpenAI when making an account. We can't tell you or guarantee how secure these prompts are when sent to OpenAI. We don’t know what OpenAI does with your prompts, but OpenAI is clear that they use prompts and results to improve their model (see their terms of use) unless you opt-out explicitly by contacting them. The code is designed to ONLY share the highlighted/selected text, or a prompt you build with the help of one of our apps and no other elements of your R environment. Make sure you are aware of what you send to OpenAI and do not accidentally share sensitive data with OpenAI.
**DO NOT HIGHLIGHT, OR INCLUDE IN A PROMPT, AND THEREFORE UPLOAD, DATA/CODE/TEXT THAT SHOULD REMAIN PRIVATE**
## Prerequisites
1. Make an OpenAI account. As of now, the free one will do.
2. [Create an OpenAI API key](https://beta.openai.com/account/api-keys) to use `{openai}` package within Rstudio
3. Set the API key up in Rstudio in one of two ways:
- By default, functions of `{openai}` will look for `OPENAI_API_KEY` environment variable. If you want to set a global environment variable, you can use the following command, where `"<APIKEY>"` should be replaced with your actual key:
```{r}
#| eval: false
Sys.setenv(OPENAI_API_KEY = "<APIKEY>")
```
- Alternatively, you can set the key in your .Renviron file.
Otherwise, you can add the key to the .Renviron file of the project. The following commands will open .Renviron for editing:
```{r}
#| eval: false
require(usethis)
edit_r_environ(scope = "project")
```
You can add the following line to the file (again, replace `"<APIKEY>"` with your actual key):
``` bash
OPENAI_API_KEY= "<APIKEY>")
```
This now set the API key every time you start up this particular project. Note: If you are using GitHub/Gitlab, do not forget to add .Renviron to .gitignore!
## Usage
Some examples of use.
### Chat with GPT in Quarto
1. **Addins \> GPTSTUDIO \> Start GPT Chat**
2. Type your question.
3. **Addins \> GPTSTUDIO \> GPT Chat
<video src="https://user-images.githubusercontent.com/6314313/210177908-7cf0f991-54f2-4f96-8bcd-3077bc8bbb25.mov" data-canonical-src="https://user-images.githubusercontent.com/6314313/210177908-7cf0f991-54f2-4f96-8bcd-3077bc8bbb25.mov" controls="controls" muted="muted" class="d-block rounded-bottom-2 width-fit" style="max-height:640px;">
</video>
### Spelling ang grammar check
**Addins \> GPTSTUDIO \> Spelling and Grammar:** Takes the selected text sends it to OpenAI's best model and instructs it to return a spelling and grammar checked version.

### Active voice
**Addins \> GPTSTUDIO \> Change text to active voice:** Takes the selected text, sends it to OpenAI's best model and instructs it to return the text in the active voice.

#### Write/code from prompt
**Addins \> GPTSTUDIO \> Write/Code from prompt:** Takes the selected text and sends it to OpenAI as a prompt for the model to work with. This is most like the ChatGPT experience.
Text from prompt:

Code from prompt:

### Comment your code:
**Addins \> GPTSTUDIO \> Comment your code:** Takes the selected text sends it to OpenAI as a prompt for a code specific model to work with, asks for a version with a comment added explaining the code line by line.

### Provide your own instructions
**Addins \> GPTSTUDIO \> Freeform GPT editor:** Apply any edit what YOU desire or can dream up to a selection of code or text.
