mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-25 12:11:03 +00:00
feat: add wit.ai support
This commit is contained in:
@@ -1,21 +1,10 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
// Fix __dirname not being defined in ES modules. (https://stackoverflow.com/a/64383997)
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname } from 'node:path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const config = JSON.parse(readFileSync('./config.json', 'utf-8'));
|
||||
|
||||
import { createServer } from 'node:net';
|
||||
import { deserialize } from 'bson';
|
||||
import transformers from 'transformers-nodejs';
|
||||
import { runAI, runOCR } from './events/index.js';
|
||||
|
||||
const tokenizer = await transformers.AutoTokenizer.fromPretrained(config.transformers.tokenizer);
|
||||
const model = await transformers.AutoModelForSeq2SeqLM.fromPretrained(config.transformers.model);
|
||||
|
||||
const server = createServer(async (client) => {
|
||||
client.on('data', async (data) => {
|
||||
const eventData = deserialize(data, {
|
||||
@@ -24,7 +13,7 @@ const server = createServer(async (client) => {
|
||||
|
||||
switch (eventData.op) {
|
||||
case 1: {
|
||||
runAI(client, eventData, tokenizer, model, config.transformers);
|
||||
runAI(client, eventData, config.witAI);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user