mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 03:01:10 +03:00
@@ -114,11 +114,14 @@ const updateChatflow = async (req: Request, res: Response, next: NextFunction) =
|
|||||||
if (!chatflow) {
|
if (!chatflow) {
|
||||||
return res.status(404).send(`Chatflow ${req.params.id} not found`)
|
return res.status(404).send(`Chatflow ${req.params.id} not found`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = req.body
|
const body = req.body
|
||||||
const updateChatFlow = new ChatFlow()
|
const updateChatFlow = new ChatFlow()
|
||||||
Object.assign(updateChatFlow, body)
|
Object.assign(updateChatFlow, body)
|
||||||
|
|
||||||
updateChatFlow.id = chatflow.id
|
updateChatFlow.id = chatflow.id
|
||||||
createRateLimiter(updateChatFlow)
|
createRateLimiter(updateChatFlow)
|
||||||
|
|
||||||
const apiResponse = await chatflowsService.updateChatflow(chatflow, updateChatFlow)
|
const apiResponse = await chatflowsService.updateChatflow(chatflow, updateChatFlow)
|
||||||
return res.json(apiResponse)
|
return res.json(apiResponse)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -217,11 +217,12 @@ const saveChatflow = async (newChatFlow: ChatFlow): Promise<any> => {
|
|||||||
const updateChatflow = async (chatflow: ChatFlow, updateChatFlow: ChatFlow): Promise<any> => {
|
const updateChatflow = async (chatflow: ChatFlow, updateChatFlow: ChatFlow): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
const appServer = getRunningExpressApp()
|
const appServer = getRunningExpressApp()
|
||||||
if (containsBase64File(updateChatFlow)) {
|
if (updateChatFlow.flowData && containsBase64File(updateChatFlow)) {
|
||||||
updateChatFlow.flowData = updateFlowDataWithFilePaths(chatflow.id, updateChatFlow.flowData)
|
updateChatFlow.flowData = updateFlowDataWithFilePaths(chatflow.id, updateChatFlow.flowData)
|
||||||
}
|
}
|
||||||
const newDbChatflow = await appServer.AppDataSource.getRepository(ChatFlow).merge(chatflow, updateChatFlow)
|
const newDbChatflow = appServer.AppDataSource.getRepository(ChatFlow).merge(chatflow, updateChatFlow)
|
||||||
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(newDbChatflow)
|
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(newDbChatflow)
|
||||||
|
|
||||||
// chatFlowPool is initialized only when a flow is opened
|
// chatFlowPool is initialized only when a flow is opened
|
||||||
// if the user attempts to rename/update category without opening any flow, chatFlowPool will be undefined
|
// if the user attempts to rename/update category without opening any flow, chatFlowPool will be undefined
|
||||||
if (appServer.chatflowPool) {
|
if (appServer.chatflowPool) {
|
||||||
|
|||||||
Reference in New Issue
Block a user