Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manager/dist/assets/index-CXH2BdD4.css

Large diffs are not rendered by default.

381 changes: 381 additions & 0 deletions manager/dist/assets/index-D-oOjDYe.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion manager/dist/assets/index-DNOCacL_.css

This file was deleted.

381 changes: 0 additions & 381 deletions manager/dist/assets/index-mxi8bQ4k.js

This file was deleted.

4 changes: 2 additions & 2 deletions manager/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/png" href="https://evolution-api.com/files/evo/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Evolution Manager</title>
<script type="module" crossorigin src="/assets/index-mxi8bQ4k.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DNOCacL_.css">
<script type="module" crossorigin src="/assets/index-D-oOjDYe.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CXH2BdD4.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class EvolutionStartupService extends ChannelStartupService {
openAiDefaultSettings.speechToText &&
received?.message?.audioMessage
) {
messageRaw.message.speechToText = await this.openaiService.speechToText(received);
messageRaw.message.speechToText = await this.openaiService.speechToText(received, this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ export class BaileysStartupService extends ChannelStartupService {
});

if (openAiDefaultSettings && openAiDefaultSettings.openaiCredsId && openAiDefaultSettings.speechToText) {
messageRaw.message.speechToText = await this.openaiService.speechToText(received);
messageRaw.message.speechToText = await this.openaiService.speechToText(received, this);
}
}

Expand Down Expand Up @@ -2324,7 +2324,7 @@ export class BaileysStartupService extends ChannelStartupService {
});

if (openAiDefaultSettings && openAiDefaultSettings.openaiCredsId && openAiDefaultSettings.speechToText) {
messageRaw.message.speechToText = await this.openaiService.speechToText(messageRaw);
messageRaw.message.speechToText = await this.openaiService.speechToText(messageRaw, this);
}
}

Expand Down
33 changes: 19 additions & 14 deletions src/api/integrations/chatbot/base-chatbot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,25 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
? pushName
: null;

session = (
await this.createNewSession(
{
instanceName: instance.instanceName,
instanceId: instance.instanceId,
},
{
remoteJid,
pushName: pushNameValue,
botId: (bot as any).id,
},
this.getBotType(),
)
)?.session;
const sessionResult = await this.createNewSession(
{
instanceName: instance.instanceName,
instanceId: instance.instanceId,
},
{
remoteJid,
pushName: pushNameValue,
botId: (bot as any).id,
},
this.getBotType(),
);

if (!sessionResult || !sessionResult.session) {
this.logger.error('Failed to create new session');
return;
}

session = sessionResult.session;
}

// Update session status to opened
Expand Down
60 changes: 4 additions & 56 deletions src/api/integrations/chatbot/dify/controllers/dify.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class DifyController extends BaseChatbotController<DifyModel, DifyDto> {
}
}

// Bots
// Override createBot to add Dify-specific validation
public async createBot(instance: InstanceDto, data: DifyDto) {
if (!this.integrationEnabled) throw new BadRequestException('Dify is disabled');

Expand All @@ -92,7 +92,7 @@ export class DifyController extends BaseChatbotController<DifyModel, DifyDto> {
})
.then((instance) => instance.id);

// Check for Dify-specific duplicate
// Dify-specific duplicate check
const checkDuplicate = await this.botRepository.findFirst({
where: {
instanceId: instanceId,
Expand All @@ -106,62 +106,10 @@ export class DifyController extends BaseChatbotController<DifyModel, DifyDto> {
throw new Error('Dify already exists');
}

// Let the base class handle the rest of the bot creation process
// Let the base class handle the rest
return super.createBot(instance, data);
}

public async findBot(instance: InstanceDto) {
if (!this.integrationEnabled) throw new BadRequestException('Dify is disabled');

const instanceId = await this.prismaRepository.instance
.findFirst({
where: {
name: instance.instanceName,
},
})
.then((instance) => instance.id);

const bots = await this.botRepository.findMany({
where: {
instanceId: instanceId,
},
});

if (!bots.length) {
return null;
}

return bots;
}

public async fetchBot(instance: InstanceDto, botId: string) {
if (!this.integrationEnabled) throw new BadRequestException('Dify is disabled');

const instanceId = await this.prismaRepository.instance
.findFirst({
where: {
name: instance.instanceName,
},
})
.then((instance) => instance.id);

const bot = await this.botRepository.findFirst({
where: {
id: botId,
},
});

if (!bot) {
throw new Error('Dify not found');
}

if (bot.instanceId !== instanceId) {
throw new Error('Dify not found');
}

return bot;
}

// Process Dify-specific bot logic
protected async processBot(
instance: any,
Expand All @@ -173,6 +121,6 @@ export class DifyController extends BaseChatbotController<DifyModel, DifyDto> {
pushName?: string,
msg?: any,
) {
this.difyService.process(instance, remoteJid, bot, session, settings, content, pushName, msg);
await this.difyService.process(instance, remoteJid, bot, session, settings, content, pushName, msg);
}
}
3 changes: 1 addition & 2 deletions src/api/integrations/chatbot/dify/dto/dify.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { $Enums } from '@prisma/client';
import { BaseChatbotDto, BaseChatbotSettingDto } from '../../base-chatbot.dto';

export class DifyDto extends BaseChatbotDto {
// Dify specific fields
botType?: $Enums.DifyBotType;
apiUrl?: string;
apiKey?: string;
}

export class DifySettingDto extends BaseChatbotSettingDto {
// Dify specific fields
difyIdFallback?: string;
}
Loading