-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt-chatgpt.R
26 lines (23 loc) · 1.01 KB
/
prompt-chatgpt.R
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
# The code below (not run) was used to access the ChatGPT API from R,
# which is a paid service with an account on the OpenAI Platform.
# Using the web version of ChatGPT 3.5 is free and sufficient for this task.
# Load packages
library(openai) # Access ChatGPT from R
# Submit request to ChatGPT
answer = create_chat_completion(
model = "gpt-3.5-turbo",
messages = list(
list(
"role" = "user",
"content" = "I have 5 topics, each described by 5 words. The keywords are as follows:
- The words for Topic 1 are: nitrogen emissions nature farmers permit.
- The words for Topic 2 are: water soil energy level time.
- The words for Topic 3 are: service delivery dutch opinion hours.
- The words for Topic 4 are: nature biodiversity land aerius species.
- The words for Topic 5 are: farmers agriculture european agricultural time.
How would you name these topics? Use maximum two words to name the topics and provide a one-sentence description for each."
)
)
)
# Display answer
cat(answer$choices$message.content)