fix(basic.gblib): #196 Spellchecker in groups now working.
This commit is contained in:
parent
3affd82c6d
commit
45ad0c3894
5 changed files with 26 additions and 12 deletions
|
@ -94,7 +94,7 @@
|
||||||
"botframework-connector": "4.18.0",
|
"botframework-connector": "4.18.0",
|
||||||
"botlib": "3.0.9",
|
"botlib": "3.0.9",
|
||||||
"c3-chart-maker": "0.2.8",
|
"c3-chart-maker": "0.2.8",
|
||||||
"cd": "^0.3.3",
|
"cd": "0.3.3",
|
||||||
"chatgpt": "2.4.2",
|
"chatgpt": "2.4.2",
|
||||||
"chrome-remote-interface": "0.31.3",
|
"chrome-remote-interface": "0.31.3",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
"puppeteer": "19.6.3",
|
"puppeteer": "19.6.3",
|
||||||
"puppeteer-extra": "3.3.4",
|
"puppeteer-extra": "3.3.4",
|
||||||
"puppeteer-extra-plugin-stealth": "2.11.1",
|
"puppeteer-extra-plugin-stealth": "2.11.1",
|
||||||
"qr-scanner": "^1.4.2",
|
"qr-scanner": "1.4.2",
|
||||||
"qrcode": "1.5.1",
|
"qrcode": "1.5.1",
|
||||||
"qrcode-terminal": "0.12.0",
|
"qrcode-terminal": "0.12.0",
|
||||||
"readline": "1.3.0",
|
"readline": "1.3.0",
|
||||||
|
|
|
@ -45,11 +45,10 @@ import { WebAutomationServices } from './services/WebAutomationServices.js';
|
||||||
import { ImageProcessingServices } from './services/ImageProcessingServices.js';
|
import { ImageProcessingServices } from './services/ImageProcessingServices.js';
|
||||||
import { DebuggerService } from './services/DebuggerService.js';
|
import { DebuggerService } from './services/DebuggerService.js';
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import { createRpcServer, createRpcClient } from '@push-rpc/core';
|
import { createRpcServer } from '@push-rpc/core';
|
||||||
import { createHttpKoaMiddleware, createHttpClient } from '@push-rpc/http';
|
import { createHttpKoaMiddleware } from '@push-rpc/http';
|
||||||
import { HttpServerOptions } from '@push-rpc/http/dist/server.js';
|
import { HttpServerOptions } from '@push-rpc/http/dist/server.js';
|
||||||
import { GBServer } from '../../src/app.js';
|
import { GBServer } from '../../src/app.js';
|
||||||
const app = new Koa();
|
|
||||||
import { SocketServer } from '@push-rpc/core';
|
import { SocketServer } from '@push-rpc/core';
|
||||||
import * as koaBody from 'koa-body';
|
import * as koaBody from 'koa-body';
|
||||||
import { GBVMService } from './services/GBVMService.js';
|
import { GBVMService } from './services/GBVMService.js';
|
||||||
|
@ -67,6 +66,8 @@ export function createKoaHttpServer(
|
||||||
app.use(koaBody.koaBody({ multipart: true }));
|
app.use(koaBody.koaBody({ multipart: true }));
|
||||||
app.use(middleware);
|
app.use(middleware);
|
||||||
const server = app.listen(port);
|
const server = app.listen(port);
|
||||||
|
const SERVER_TIMEOUT = 60 * 1000;
|
||||||
|
server.timeout = SERVER_TIMEOUT;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onError,
|
onError,
|
||||||
|
|
|
@ -1319,6 +1319,16 @@ export class GBMinService {
|
||||||
|
|
||||||
text = await min.conversationalService.spellCheck(min, textProcessed);
|
text = await min.conversationalService.spellCheck(min, textProcessed);
|
||||||
|
|
||||||
|
// If it is a group, spells and sends them back.
|
||||||
|
|
||||||
|
const group = step.context.activity['group'];
|
||||||
|
if (textProcessed !== text && group){
|
||||||
|
await min.whatsAppDirectLine.sendToDevice(
|
||||||
|
group,
|
||||||
|
`Spell: ${text}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Detects user typed language and updates their locale profile if applies.
|
// Detects user typed language and updates their locale profile if applies.
|
||||||
|
|
||||||
let locale = min.core.getParam<string>(
|
let locale = min.core.getParam<string>(
|
||||||
|
|
|
@ -214,7 +214,7 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// TODO: https://github.com/GeneralBots/BotServer/issues/9 user.lastQuestion = text;
|
// TODO: https://github.com/GeneralBots/BotServer/issues/9 user.lastQuestion = text;
|
||||||
|
|
||||||
const resultsA = await service.ask(min.instance, text, searchScore, null /* user.subjects */ );
|
const resultsA = await service.ask(min.instance, text, searchScore, null /* user.subjects */);
|
||||||
|
|
||||||
// If there is some result, answer immediately.
|
// If there is some result, answer immediately.
|
||||||
|
|
||||||
|
@ -224,13 +224,12 @@ export class AskDialog extends IGBDialog {
|
||||||
// user.isAsking = false;
|
// user.isAsking = false;
|
||||||
// user.lastQuestionId = resultsA.questionId;
|
// user.lastQuestionId = resultsA.questionId;
|
||||||
|
|
||||||
|
|
||||||
// Sends the answer to all outputs, including projector.
|
// Sends the answer to all outputs, including projector.
|
||||||
|
|
||||||
answer = resultsA.answer;
|
answer = resultsA.answer;
|
||||||
|
|
||||||
// If this search was restricted to some subjects...
|
// If this search was restricted to some subjects...
|
||||||
}
|
}
|
||||||
// TODO: https://github.com/GeneralBots/BotServer/issues/9
|
// TODO: https://github.com/GeneralBots/BotServer/issues/9
|
||||||
// else if (user.subjects && user.subjects.length > 0) {
|
// else if (user.subjects && user.subjects.length > 0) {
|
||||||
// // ...second time running Search, now with no filter.
|
// // ...second time running Search, now with no filter.
|
||||||
|
@ -244,7 +243,6 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// // user2.isAsking = false;
|
// // user2.isAsking = false;
|
||||||
// // user2.lastQuestionId = resultsB.questionId;
|
// // user2.lastQuestionId = resultsB.questionId;
|
||||||
|
|
||||||
|
|
||||||
// // Informs user that a broader search will be used.
|
// // Informs user that a broader search will be used.
|
||||||
|
|
||||||
|
@ -302,13 +300,14 @@ export class AskDialog extends IGBDialog {
|
||||||
});
|
});
|
||||||
await GBServer.globals.chatGPT.init();
|
await GBServer.globals.chatGPT.init();
|
||||||
}
|
}
|
||||||
|
const CHATGPT_TIMEOUT = 60 * 1000;
|
||||||
GBLog.info(`ChatGPT being used...`);
|
GBLog.info(`ChatGPT being used...`);
|
||||||
const response = await GBServer.globals.chatGPT.sendMessage(text);
|
const response = await GBServer.globals.chatGPT.sendMessage(text,
|
||||||
|
{ timeoutMs: CHATGPT_TIMEOUT });
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
GBLog.info(`SEARCH called but NO answer could be found (zero results).`);
|
GBLog.info(`SEARCH called but NO answer could be found (zero results).`);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
await min.conversationalService.sendText(min, step, response);
|
await min.conversationalService.sendText(min, step, response);
|
||||||
}
|
}
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
|
|
|
@ -1019,9 +1019,13 @@ export class WhatsappDirectLine extends GBService {
|
||||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||||
return; // EXIT HERE.
|
return; // EXIT HERE.
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GBLog.warn(`Group: ${group} not associated with botId:${botId}.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detects if the welcome message is enabled.
|
// Detects if the welcome message is enabled.z
|
||||||
|
|
||||||
if (process.env.WHATSAPP_WELCOME_DISABLED !== 'true') {
|
if (process.env.WHATSAPP_WELCOME_DISABLED !== 'true') {
|
||||||
// Tries to find if user wants to switch bots.
|
// Tries to find if user wants to switch bots.
|
||||||
|
|
Loading…
Add table
Reference in a new issue