mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
changes & fixes for various issues in chatflow config (#4314)
* Chatflow config - rate limit and override config were overwriting changes. * prevent post processing JS function from escaping as JSON... * non-streaming follow up prompts need to be escaped twice * prevent post processing JS function from escaping as JSON... * Adding file mimetypes for full file upload... * lint.. * fixing the issue with storing only filtered nodes.. * return doc store processing response without await when queue mode and request is from UI --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
mapMimeTypeToInputField,
|
||||
mapExtToInputField,
|
||||
getFileFromUpload,
|
||||
removeSpecificFileFromUpload
|
||||
removeSpecificFileFromUpload,
|
||||
handleEscapeCharacters
|
||||
} from 'flowise-components'
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
import {
|
||||
@@ -665,6 +666,7 @@ export const executeFlow = async ({
|
||||
const postProcessingFunction = JSON.parse(chatflowConfig?.postProcessing?.customFunction)
|
||||
const nodeInstanceFilePath = componentNodes['customFunction'].filePath as string
|
||||
const nodeModule = await import(nodeInstanceFilePath)
|
||||
//set the outputs.output to EndingNode to prevent json escaping of content...
|
||||
const nodeData = {
|
||||
inputs: { javascriptFunction: postProcessingFunction },
|
||||
outputs: { output: 'output' }
|
||||
@@ -681,7 +683,13 @@ export const executeFlow = async ({
|
||||
}
|
||||
const customFuncNodeInstance = new nodeModule.nodeClass()
|
||||
let moderatedResponse = await customFuncNodeInstance.init(nodeData, question, options)
|
||||
result.text = moderatedResponse
|
||||
if (typeof moderatedResponse === 'string') {
|
||||
result.text = handleEscapeCharacters(moderatedResponse, true)
|
||||
} else if (typeof moderatedResponse === 'object') {
|
||||
result.text = '```json\n' + JSON.stringify(moderatedResponse, null, 2) + '\n```'
|
||||
} else {
|
||||
result.text = moderatedResponse
|
||||
}
|
||||
resultText = result.text
|
||||
} catch (e) {
|
||||
logger.log('[server]: Post Processing Error:', e)
|
||||
|
||||
Reference in New Issue
Block a user