Skip to content

Commit 98502f6

Browse files
committed
fix: resolve build errors and audio transcription issues across chatbot services
- Add YAML file loader to tsup.config.ts to fix build compilation errors - Fix OpenAI speechToText method signature across all chatbot services - Correct DifyService constructor parameter order in server.module.ts and channel.service.ts - Add missing OpenAI service dependency injection to EvoaiService - Standardize audio transcription logic in FlowiseService to match N8N implementation - Fix speechToText calls in WhatsApp Baileys and Evolution channel services - Ensure consistent error handling and parameter passing for audio processing This resolves the "Cannot read properties of undefined" errors and ensures all chatbot integrations (OpenAI, N8N, Flowise, EvoAI, Dify, EvolutionBot) properly handle audio message transcription using OpenAI Whisper.
1 parent 3fc77e4 commit 98502f6

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

src/api/integrations/channel/evolution/evolution.channel.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class EvolutionStartupService extends ChannelStartupService {
165165
openAiDefaultSettings.speechToText &&
166166
received?.message?.audioMessage
167167
) {
168-
messageRaw.message.speechToText = await this.openaiService.speechToText(received);
168+
messageRaw.message.speechToText = await this.openaiService.speechToText(received, this);
169169
}
170170
}
171171

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ export class BaileysStartupService extends ChannelStartupService {
12981298
});
12991299

13001300
if (openAiDefaultSettings && openAiDefaultSettings.openaiCredsId && openAiDefaultSettings.speechToText) {
1301-
messageRaw.message.speechToText = await this.openaiService.speechToText(received);
1301+
messageRaw.message.speechToText = await this.openaiService.speechToText(received, this);
13021302
}
13031303
}
13041304

@@ -2324,7 +2324,7 @@ export class BaileysStartupService extends ChannelStartupService {
23242324
});
23252325

23262326
if (openAiDefaultSettings && openAiDefaultSettings.openaiCredsId && openAiDefaultSettings.speechToText) {
2327-
messageRaw.message.speechToText = await this.openaiService.speechToText(messageRaw);
2327+
messageRaw.message.speechToText = await this.openaiService.speechToText(messageRaw, this);
23282328
}
23292329
}
23302330

src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class EvolutionBotService extends BaseChatbotService<EvolutionBot, Evolut
6262
if (this.isAudioMessage(content) && msg) {
6363
try {
6464
this.logger.debug(`[EvolutionBot] Downloading audio for Whisper transcription`);
65-
const transcription = await this.openaiService.speechToText(msg);
65+
const transcription = await this.openaiService.speechToText(msg, instance);
6666
if (transcription) {
6767
payload.query = transcription;
6868
} else {

src/api/server.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const openaiController = new OpenaiController(openaiService, prismaReposi
123123
const typebotService = new TypebotService(waMonitor, configService, prismaRepository, openaiService);
124124
export const typebotController = new TypebotController(typebotService, prismaRepository, waMonitor);
125125

126-
const difyService = new DifyService(waMonitor, configService, prismaRepository, openaiService);
126+
const difyService = new DifyService(waMonitor, prismaRepository, configService, openaiService);
127127
export const difyController = new DifyController(difyService, prismaRepository, waMonitor);
128128

129129
const evolutionBotService = new EvolutionBotService(waMonitor, configService, prismaRepository, openaiService);

src/api/services/channel.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class ChannelStartupService {
4949

5050
public typebotService = new TypebotService(waMonitor, this.configService, this.prismaRepository, this.openaiService);
5151

52-
public difyService = new DifyService(waMonitor, this.configService, this.prismaRepository, this.openaiService);
52+
public difyService = new DifyService(waMonitor, this.prismaRepository, this.configService, this.openaiService);
5353

5454
public setInstance(instance: InstanceDto) {
5555
this.logger.setInstance(instance.instanceName);

tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ export default defineConfig({
1515
},
1616
loader: {
1717
'.json': 'file',
18+
'.yml': 'file',
1819
},
1920
});

0 commit comments

Comments
 (0)