-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.mjs
56 lines (50 loc) · 1.33 KB
/
script.mjs
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
import fs from 'fs';
const orgKey = '[redacted]';
const apiKey = '[redacted]';
import { Configuration, OpenAIApi } from "openai";
const hobbies = [
"Photography",
"Painting",
"Cooking",
"Gardening",
"Playing a musical instrument",
"Writing",
"Reading",
"Knitting",
"Dancing",
"Hiking",
"Cycling",
"Swimming",
"Yoga",
"Playing chess",
"Collecting stamps",
"Birdwatching",
"Sculpting",
"Pottery",
"Fishing",
"Playing video games",
"Woodworking",
"Calligraphy",
"Sewing",
"Origami",
"Playing tennis"
];
const configuration = new Configuration({
apiKey: apiKey,
});
const openai = new OpenAIApi(configuration);
for (const hobby of hobbies) {
const systemMessage = `You are someone with a ${hobby} hobby. Please describe your hobby ${hobby} in 3 sentences.`;
const userMessage = `Please describe your hobby ${hobby} in 3 sentences.`;
const chatCompletion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: systemMessage },
{ role: "user", content: userMessage }
],
});
const output = chatCompletion.data.choices[0].message.content;
const outputString = JSON.stringify(output);
fs.writeFileSync('output.txt', outputString + '\n', { flag: 'a' });
console.log(output);
}