mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-29 22:21:02 +00:00
feat: training and replies changed
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
The server uses TCP for connection and BSON for messages, so you need to serialize and deserialize the messages.
|
||||
|
||||
# AI
|
||||
## AI
|
||||
|
||||
Sending the server this JSON (BSON) will send you back the AI predictions.
|
||||
|
||||
@@ -20,11 +20,28 @@ And the server would return something like this:
|
||||
{
|
||||
"op": 2,
|
||||
"id": "String",
|
||||
"response": "I think the term afn is just a generic slang term for the app that allows you to modify the behavior of Dalvik based android application..."
|
||||
"response": [
|
||||
{
|
||||
"confidence": 0.99,
|
||||
"id": "String",
|
||||
"name": "revanced_download"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Training the AI
|
||||
|
||||
To train the AI, send the server a JSON (BSON) like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"op": 3,
|
||||
"label": "revanced_download",
|
||||
"text": "how to download revanced"
|
||||
}
|
||||
```
|
||||
|
||||
# OCR
|
||||
## OCR
|
||||
|
||||
Sending the server this JSON (BSON) will send you back the read text.
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { serialize } from 'bson';
|
||||
|
||||
export default async function runAI(client, data, config) {
|
||||
const witAIReq = await fetch(`https://api.wit.ai/message?v20230319&q=${encodeURI(data.text)}`, {
|
||||
headers: {
|
||||
authorization: `Bearer ${config.authToken}`
|
||||
const witAIReq = await fetch(
|
||||
`https://api.wit.ai/message?v20230319&q=${encodeURI(data.text)}`,
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bearer ${config.authToken}`
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
const response = await witAIReq.json();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import runAI from './ai.js';
|
||||
import runOCR from './ocr.js';
|
||||
import trainAI from './train.js';
|
||||
|
||||
export { runAI, runOCR };
|
||||
export { runAI, runOCR, trainAI };
|
||||
|
||||
18
server/events/train.js
Normal file
18
server/events/train.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export default async function runAI(data, config) {
|
||||
fetch('https://api.wit.ai/utterances', {
|
||||
headers: {
|
||||
authorization: `Bearer ${config.authToken}`
|
||||
},
|
||||
body: JSON.stringify([
|
||||
{
|
||||
text: data.text,
|
||||
intent: data.label,
|
||||
entities: [],
|
||||
traits: []
|
||||
}
|
||||
]),
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ const config = JSON.parse(readFileSync('./config.json', 'utf-8'));
|
||||
|
||||
import { createServer } from 'node:net';
|
||||
import { deserialize } from 'bson';
|
||||
import { runAI, runOCR } from './events/index.js';
|
||||
import { runAI, runOCR, trainAI } from './events/index.js';
|
||||
|
||||
const server = createServer(async (client) => {
|
||||
client.on('data', async (data) => {
|
||||
@@ -17,6 +17,11 @@ const server = createServer(async (client) => {
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
trainAI(eventData, config.witAI);
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: {
|
||||
runOCR(client, eventData);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user