Remove unnecessary code

This commit is contained in:
Ilango Rajagopal 2025-09-18 13:28:16 +05:30
parent f64900b8b8
commit b514a82728
4 changed files with 2 additions and 41 deletions

View File

@ -3,7 +3,6 @@ import { utilBuildChatflow } from '../../utils/buildChatflow'
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
import { getErrorMessage } from '../../errors/utils'
import { MODE } from '../../Interface'
import { generateTTSForResponseStream, shouldAutoPlayTTS } from '../../utils/buildChatflow'
// Send input message and get prediction result (Internal)
const createInternalPrediction = async (req: Request, res: Response, next: NextFunction) => {
@ -39,26 +38,6 @@ const createAndStreamInternalPrediction = async (req: Request, res: Response, ne
const apiResponse = await utilBuildChatflow(req, true)
sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse)
const chatflow = req.body.chatflow || req.body
if (shouldAutoPlayTTS(chatflow.textToSpeech) && apiResponse.text) {
const options = {
orgId: req.body.orgId || '',
chatflowid: req.body.chatflowid || '',
chatId: apiResponse.chatId,
appDataSource: getRunningExpressApp().AppDataSource,
databaseEntities: getRunningExpressApp().AppDataSource?.entityMetadatas || []
}
await generateTTSForResponseStream(
apiResponse.text,
chatflow.textToSpeech,
options,
apiResponse.chatId,
apiResponse.chatMessageId,
sseStreamer
)
}
} catch (error) {
if (chatId) {
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))

View File

@ -77,26 +77,6 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction)
const apiResponse = await predictionsServices.buildChatflow(req)
sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse)
const chatflow = await chatflowsService.getChatflowById(req.params.id)
if (chatflow && shouldAutoPlayTTS(chatflow.textToSpeech) && apiResponse.text) {
const options = {
orgId: req.body.orgId || '',
chatflowid: req.params.id,
chatId: apiResponse.chatId,
appDataSource: getRunningExpressApp().AppDataSource,
databaseEntities: getRunningExpressApp().AppDataSource?.entityMetadatas || []
}
await generateTTSForResponseStream(
apiResponse.text,
chatflow.textToSpeech,
options,
apiResponse.chatId,
apiResponse.chatMessageId,
sseStreamer
)
}
} catch (error) {
if (chatId) {
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))

View File

@ -2180,6 +2180,7 @@ export const executeAgentFlow = async ({
if (sessionId) result.sessionId = sessionId
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
logger.info('Generating TTS for response in executeAgentFlow')
const options = {
orgId,
chatflowid,

View File

@ -899,6 +899,7 @@ export const executeFlow = async ({
if (Object.keys(setVariableNodesOutput).length) result.flowVariables = setVariableNodesOutput
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
logger.info('Generating TTS for response in executeFlow')
const options = {
orgId,
chatflowid,