forked from Snorfield/Train-Your-Own-Prediction-Model
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.js
More file actions
75 lines (57 loc) · 2.12 KB
/
setup.js
File metadata and controls
75 lines (57 loc) · 2.12 KB
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
const readline = require('readline').promises;
const fs = require('fs');
const parse = require('./parse');
const train = require('./train');
(async () => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const jsonPath = await rl.question("Input your index.json path: ");
if (!fs.existsSync(jsonPath)) {
console.warn('[!] Could not find file at specified path');
rl.close();
process.exit(0);
}
let index = require(jsonPath);
const messagesPath = await rl.question("Input your message folder path: ");
if (!fs.existsSync(messagesPath) || !fs.lstatSync(messagesPath).isDirectory()) {
console.warn('[!] Could not find folder at specified path');
rl.close();
process.exit(0);
}
console.log("[+] Paths verified, attempting to parse data");
console.log("[*] Loading configurations from config.json");
rl.close();
let config = {};
if (!fs.existsSync('./config.json')) {
console.warn('[!] Could not locate config.json, parsing with default values');
} else {
config = require('./config.json');
}
let filteredServers = config.filteredServers ?? [];
let filteredThreads = config.filteredThreads ?? [];
let filteredChannels = config.filteredChannels ?? [];
let filterDms = config.filterDms ?? true;
let filterGroupChats = config.filterGroupChats ?? true;
config = {
filteredServers,
filteredThreads,
filteredChannels,
filterDms,
filterGroupChats,
jsonPath,
messagesPath
};
parse(config, index);
console.log("[*] Parsing done, moving on to training.")
let data = [];
if (!fs.existsSync('./output.json')) {
console.warn('[!] Could not locate output.json, training terminated.');
process.exit(0);
} else {
data = require('./output.json');
}
train(data);
console.log("[+] Model successfully generated. Run 'node chat' to start a chat session with the model!")
})();