mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat: "add train data" event
This commit is contained in:
16
server/events/addTrainData.js
Normal file
16
server/events/addTrainData.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
export default function addTrainData(eventData) {
|
||||
const file = readFileSync(join(global.__dirname, global.config.fasttext.trainData), 'utf-8');
|
||||
const data = file.split('\n');
|
||||
const { label, text } = eventData;
|
||||
|
||||
const labelIndex = data.findIndex((data) => data.startsWith(label));
|
||||
|
||||
data.splice(labelIndex === -1 ? 0 : labelIndex, 0, `${label} ${text}`);
|
||||
|
||||
writeFileSync(join(global.__dirname, global.config.fasttext.trainData), data.join('\n'));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export default async function runAI(client, data) {
|
||||
id: data.id,
|
||||
predictions
|
||||
};
|
||||
console.log(predictions)
|
||||
|
||||
const bsonData = serialize(jsonData);
|
||||
client.write(bsonData);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ global.__dirname = dirname(__filename);
|
||||
const configJSON = readFileSync('./config.json', 'utf-8');
|
||||
const config = JSON.parse(configJSON);
|
||||
global.config = config;
|
||||
console.log(config);
|
||||
import { createServer } from 'node:net';
|
||||
import { deserialize } from 'bson';
|
||||
import FastText from 'fasttext.js';
|
||||
|
||||
Reference in New Issue
Block a user