mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-24 17:38:40 -06:00
Fix intrinsic type issues on chatbot controllers
This commit is contained in:
parent
03c32de743
commit
99161de094
@ -7,6 +7,7 @@ import { WAMonitoringService } from '@api/services/monitor.service';
|
|||||||
import { configService, Dify } from '@config/env.config';
|
import { configService, Dify } from '@config/env.config';
|
||||||
import { Logger } from '@config/logger.config';
|
import { Logger } from '@config/logger.config';
|
||||||
import { BadRequestException } from '@exceptions';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
import { Dify as DifyModel } from '@prisma/client';
|
||||||
import { getConversationMessage } from '@utils/getConversationMessage';
|
import { getConversationMessage } from '@utils/getConversationMessage';
|
||||||
|
|
||||||
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
||||||
@ -723,49 +724,25 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
const findBot = await this.findBotTrigger(
|
const findBot = (await this.findBotTrigger(
|
||||||
this.botRepository,
|
this.botRepository,
|
||||||
this.settingsRepository,
|
this.settingsRepository,
|
||||||
content,
|
content,
|
||||||
instance,
|
instance,
|
||||||
session,
|
session,
|
||||||
);
|
)) as DifyModel;
|
||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let expire = findBot.expire;
|
|
||||||
let keywordFinish = findBot.keywordFinish;
|
|
||||||
let delayMessage = findBot.delayMessage;
|
|
||||||
let unknownMessage = findBot.unknownMessage;
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let listeningFromMe = findBot.listeningFromMe;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let stopBotFromMe = findBot.stopBotFromMe;
|
||||||
let keepOpen = findBot.keepOpen;
|
|
||||||
let debounceTime = findBot.debounceTime;
|
let debounceTime = findBot.debounceTime;
|
||||||
|
|
||||||
if (
|
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
||||||
!expire ||
|
|
||||||
!keywordFinish ||
|
|
||||||
!delayMessage ||
|
|
||||||
!unknownMessage ||
|
|
||||||
!listeningFromMe ||
|
|
||||||
!stopBotFromMe ||
|
|
||||||
!keepOpen ||
|
|
||||||
!debounceTime
|
|
||||||
) {
|
|
||||||
if (!expire) expire = settings.expire;
|
|
||||||
|
|
||||||
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
|
||||||
|
|
||||||
if (!delayMessage) delayMessage = settings.delayMessage;
|
|
||||||
|
|
||||||
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
|
||||||
|
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
|
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
|
|
||||||
if (!keepOpen) keepOpen = settings.keepOpen;
|
|
||||||
|
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import { getConversationMessage } from '@utils/getConversationMessage';
|
|||||||
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
||||||
import { FlowiseDto } from '../dto/flowise.dto';
|
import { FlowiseDto } from '../dto/flowise.dto';
|
||||||
import { FlowiseService } from '../services/flowise.service';
|
import { FlowiseService } from '../services/flowise.service';
|
||||||
|
import { Flowise } from '@prisma/client';
|
||||||
|
|
||||||
export class FlowiseController extends ChatbotController implements ChatbotControllerInterface {
|
export class FlowiseController extends ChatbotController implements ChatbotControllerInterface {
|
||||||
constructor(
|
constructor(
|
||||||
@ -695,49 +696,25 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
const findBot = await this.findBotTrigger(
|
const findBot = (await this.findBotTrigger(
|
||||||
this.botRepository,
|
this.botRepository,
|
||||||
this.settingsRepository,
|
this.settingsRepository,
|
||||||
content,
|
content,
|
||||||
instance,
|
instance,
|
||||||
session,
|
session,
|
||||||
);
|
)) as Flowise;
|
||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let expire = findBot.expire;
|
|
||||||
let keywordFinish = findBot.keywordFinish;
|
|
||||||
let delayMessage = findBot.delayMessage;
|
|
||||||
let unknownMessage = findBot.unknownMessage;
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let listeningFromMe = findBot.listeningFromMe;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let stopBotFromMe = findBot.stopBotFromMe;
|
||||||
let keepOpen = findBot.keepOpen;
|
|
||||||
let debounceTime = findBot.debounceTime;
|
let debounceTime = findBot.debounceTime;
|
||||||
|
|
||||||
if (
|
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
||||||
!expire ||
|
|
||||||
!keywordFinish ||
|
|
||||||
!delayMessage ||
|
|
||||||
!unknownMessage ||
|
|
||||||
!listeningFromMe ||
|
|
||||||
!stopBotFromMe ||
|
|
||||||
!keepOpen ||
|
|
||||||
!debounceTime
|
|
||||||
) {
|
|
||||||
if (!expire) expire = settings.expire;
|
|
||||||
|
|
||||||
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
|
||||||
|
|
||||||
if (!delayMessage) delayMessage = settings.delayMessage;
|
|
||||||
|
|
||||||
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
|
||||||
|
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
|
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
|
|
||||||
if (!keepOpen) keepOpen = settings.keepOpen;
|
|
||||||
|
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { InstanceDto } from '@api/dto/instance.dto';
|
|||||||
import { PrismaRepository } from '@api/repository/repository.service';
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
import { Logger } from '@config/logger.config';
|
import { Logger } from '@config/logger.config';
|
||||||
|
import { GenericBot } from '@prisma/client';
|
||||||
import { getConversationMessage } from '@utils/getConversationMessage';
|
import { getConversationMessage } from '@utils/getConversationMessage';
|
||||||
|
|
||||||
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
|
||||||
@ -695,49 +696,25 @@ export class GenericController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
const findBot = await this.findBotTrigger(
|
const findBot = (await this.findBotTrigger(
|
||||||
this.botRepository,
|
this.botRepository,
|
||||||
this.settingsRepository,
|
this.settingsRepository,
|
||||||
content,
|
content,
|
||||||
instance,
|
instance,
|
||||||
session,
|
session,
|
||||||
);
|
)) as GenericBot;
|
||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let expire = findBot.expire;
|
|
||||||
let keywordFinish = findBot.keywordFinish;
|
|
||||||
let delayMessage = findBot.delayMessage;
|
|
||||||
let unknownMessage = findBot.unknownMessage;
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let listeningFromMe = findBot.listeningFromMe;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let stopBotFromMe = findBot.stopBotFromMe;
|
||||||
let keepOpen = findBot.keepOpen;
|
|
||||||
let debounceTime = findBot.debounceTime;
|
let debounceTime = findBot.debounceTime;
|
||||||
|
|
||||||
if (
|
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
||||||
!expire ||
|
|
||||||
!keywordFinish ||
|
|
||||||
!delayMessage ||
|
|
||||||
!unknownMessage ||
|
|
||||||
!listeningFromMe ||
|
|
||||||
!stopBotFromMe ||
|
|
||||||
!keepOpen ||
|
|
||||||
!debounceTime
|
|
||||||
) {
|
|
||||||
if (!expire) expire = settings.expire;
|
|
||||||
|
|
||||||
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
|
||||||
|
|
||||||
if (!delayMessage) delayMessage = settings.delayMessage;
|
|
||||||
|
|
||||||
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
|
||||||
|
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
|
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
|
|
||||||
if (!keepOpen) keepOpen = settings.keepOpen;
|
|
||||||
|
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { WAMonitoringService } from '@api/services/monitor.service';
|
|||||||
import { configService, Openai } from '@config/env.config';
|
import { configService, Openai } from '@config/env.config';
|
||||||
import { Logger } from '@config/logger.config';
|
import { Logger } from '@config/logger.config';
|
||||||
import { BadRequestException } from '@exceptions';
|
import { BadRequestException } from '@exceptions';
|
||||||
|
import { OpenaiBot } from '@prisma/client';
|
||||||
import { getConversationMessage } from '@utils/getConversationMessage';
|
import { getConversationMessage } from '@utils/getConversationMessage';
|
||||||
import OpenAI from 'openai';
|
import OpenAI from 'openai';
|
||||||
|
|
||||||
@ -941,54 +942,26 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
const findBot = await this.findBotTrigger(
|
const findBot = (await this.findBotTrigger(
|
||||||
this.botRepository,
|
this.botRepository,
|
||||||
this.settingsRepository,
|
this.settingsRepository,
|
||||||
content,
|
content,
|
||||||
instance,
|
instance,
|
||||||
session,
|
session,
|
||||||
);
|
)) as OpenaiBot;
|
||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
// verify default settings
|
// verify default settings
|
||||||
let openaiCredsId = findBot.openaiCredsId;
|
|
||||||
let expire = findBot.expire;
|
|
||||||
let keywordFinish = findBot.keywordFinish;
|
|
||||||
let delayMessage = findBot.delayMessage;
|
|
||||||
let unknownMessage = findBot.unknownMessage;
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let listeningFromMe = findBot.listeningFromMe;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let stopBotFromMe = findBot.stopBotFromMe;
|
||||||
let keepOpen = findBot.keepOpen;
|
|
||||||
let debounceTime = findBot.debounceTime;
|
let debounceTime = findBot.debounceTime;
|
||||||
|
|
||||||
if (
|
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
||||||
!openaiCredsId ||
|
|
||||||
!expire ||
|
|
||||||
!keywordFinish ||
|
|
||||||
!delayMessage ||
|
|
||||||
!unknownMessage ||
|
|
||||||
!listeningFromMe ||
|
|
||||||
!stopBotFromMe ||
|
|
||||||
!keepOpen ||
|
|
||||||
!debounceTime
|
|
||||||
) {
|
|
||||||
if (!openaiCredsId) openaiCredsId = settings.openaiCredsId;
|
|
||||||
|
|
||||||
if (!expire) expire = settings.expire;
|
|
||||||
|
|
||||||
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
|
||||||
|
|
||||||
if (!delayMessage) delayMessage = settings.delayMessage;
|
|
||||||
|
|
||||||
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
|
||||||
|
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
|
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
|
|
||||||
if (!keepOpen) keepOpen = settings.keepOpen;
|
|
||||||
|
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import { getConversationMessage } from '@utils/getConversationMessage';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { ChatbotController, ChatbotControllerInterface } from '../../chatbot.controller';
|
import { ChatbotController, ChatbotControllerInterface } from '../../chatbot.controller';
|
||||||
|
import { Typebot as TypebotModel } from '@prisma/client';
|
||||||
|
|
||||||
export class TypebotController extends ChatbotController implements ChatbotControllerInterface {
|
export class TypebotController extends ChatbotController implements ChatbotControllerInterface {
|
||||||
constructor(
|
constructor(
|
||||||
@ -1001,13 +1002,13 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
const findBot = await this.findBotTrigger(
|
const findBot = (await this.findBotTrigger(
|
||||||
this.botRepository,
|
this.botRepository,
|
||||||
this.settingsRepository,
|
this.settingsRepository,
|
||||||
content,
|
content,
|
||||||
instance,
|
instance,
|
||||||
session,
|
session,
|
||||||
);
|
)) as TypebotModel;
|
||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user