-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
65 lines (54 loc) · 1.88 KB
/
index.js
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
const { chunkAndSummarize } = require('./chunkk')
const { getChatGPTResponseForForm } = require('./promptTesting')
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const HELP = `
Usage:
node index.js --input [filePath]
Options:
--help, -h Show usage
For generating dataset for fine tuning pre-trained GPT models
--input, -i path file with main content
--output, -o path to output file
--numTokens, -t max number of tokens for the models
--model, -m ChatGPT model
--numIterations, -n number of iterations for questioning ChatGPT
For prompt testing
--input, -i path file with main content
--prompt, -p path to the file that contains the prompt in a valid JSON format. This is the one to tweak.
--template, -l path to the file that has JSON that needs to be filled by ChatGPT
--numTokens, -t max number of tokens for the models
--model, -m ChatGPT model
`
// node --inspect-brk index.js -n 1 -o '../Downloads/Ted.json' -t 2500 -i '../Downloads/TedChiang-The truth of fact the truth of feeling.txt'
const argv = require('minimist')(process.argv.slice(2), {
alias: {
i: 'input',
o: 'output',
t: 'numTokens',
n: 'numIterations',
m: 'model',
p: 'prompt',
l: 'template',
h: "help"
}
})
const { input, output, numIterations, help, model, numTokens, template, prompt } = argv
const tasks = []
if (help)
console.log(HELP)
else if (prompt && template) {
;(async () => {
let response = await getChatGPTResponseForForm({ input, template, prompt, model, numTokens, openai });
console.log(response)
debugger
})();
}
else if (input) {
;(async () => {
const summary = await chunkAndSummarize({input, output, numIterations, model, numTokens, openai})
})(input)
}