Remove unnecessary code
This commit is contained in:
parent
f64900b8b8
commit
b514a82728
|
|
@ -3,7 +3,6 @@ import { utilBuildChatflow } from '../../utils/buildChatflow'
|
||||||
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
|
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
|
||||||
import { getErrorMessage } from '../../errors/utils'
|
import { getErrorMessage } from '../../errors/utils'
|
||||||
import { MODE } from '../../Interface'
|
import { MODE } from '../../Interface'
|
||||||
import { generateTTSForResponseStream, shouldAutoPlayTTS } from '../../utils/buildChatflow'
|
|
||||||
|
|
||||||
// Send input message and get prediction result (Internal)
|
// Send input message and get prediction result (Internal)
|
||||||
const createInternalPrediction = async (req: Request, res: Response, next: NextFunction) => {
|
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)
|
const apiResponse = await utilBuildChatflow(req, true)
|
||||||
sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse)
|
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) {
|
} catch (error) {
|
||||||
if (chatId) {
|
if (chatId) {
|
||||||
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))
|
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))
|
||||||
|
|
|
||||||
|
|
@ -77,26 +77,6 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction)
|
||||||
|
|
||||||
const apiResponse = await predictionsServices.buildChatflow(req)
|
const apiResponse = await predictionsServices.buildChatflow(req)
|
||||||
sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse)
|
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) {
|
} catch (error) {
|
||||||
if (chatId) {
|
if (chatId) {
|
||||||
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))
|
sseStreamer.streamErrorEvent(chatId, getErrorMessage(error))
|
||||||
|
|
|
||||||
|
|
@ -2180,6 +2180,7 @@ export const executeAgentFlow = async ({
|
||||||
if (sessionId) result.sessionId = sessionId
|
if (sessionId) result.sessionId = sessionId
|
||||||
|
|
||||||
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
|
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
|
||||||
|
logger.info('Generating TTS for response in executeAgentFlow')
|
||||||
const options = {
|
const options = {
|
||||||
orgId,
|
orgId,
|
||||||
chatflowid,
|
chatflowid,
|
||||||
|
|
|
||||||
|
|
@ -899,6 +899,7 @@ export const executeFlow = async ({
|
||||||
if (Object.keys(setVariableNodesOutput).length) result.flowVariables = setVariableNodesOutput
|
if (Object.keys(setVariableNodesOutput).length) result.flowVariables = setVariableNodesOutput
|
||||||
|
|
||||||
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
|
if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) {
|
||||||
|
logger.info('Generating TTS for response in executeFlow')
|
||||||
const options = {
|
const options = {
|
||||||
orgId,
|
orgId,
|
||||||
chatflowid,
|
chatflowid,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue