diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts
index 0b1e62d2..2bf1c04a 100644
--- a/packages/server/src/utils/index.ts
+++ b/packages/server/src/utils/index.ts
@@ -558,9 +558,20 @@ export const isStartNodeDependOnInput = (startingNodes: IReactFlowNode[], nodes:
if (inputVariables.length > 0) return true
}
}
- const whitelistNodeNames = ['vectorStoreToDocument', 'autoGPT']
+ const whitelistNodeNames = ['vectorStoreToDocument', 'autoGPT', 'chatPromptTemplate', 'promptTemplate'] //If these nodes are found, chatflow cannot be reused
for (const node of nodes) {
- if (whitelistNodeNames.includes(node.data.name)) return true
+ if (node.data.name === 'chatPromptTemplate' || node.data.name === 'promptTemplate') {
+ let promptValues: ICommonObject = {}
+ const promptValuesRaw = node.data.inputs?.promptValues
+ if (promptValuesRaw) {
+ try {
+ promptValues = typeof promptValuesRaw === 'object' ? promptValuesRaw : JSON.parse(promptValuesRaw)
+ } catch (exception) {
+ console.error(exception)
+ }
+ }
+ if (getAllValuesFromJson(promptValues).includes(`{{${QUESTION_VAR_PREFIX}}}`)) return true
+ } else if (whitelistNodeNames.includes(node.data.name)) return true
}
return false
}
@@ -913,3 +924,31 @@ export const replaceChatHistory = async (
return ''
}
+
+/**
+ * Get all values from a JSON object
+ * @param {any} obj
+ * @returns {any[]}
+ */
+export const getAllValuesFromJson = (obj: any): any[] => {
+ const values: any[] = []
+
+ function extractValues(data: any) {
+ if (typeof data === 'object' && data !== null) {
+ if (Array.isArray(data)) {
+ for (const item of data) {
+ extractValues(item)
+ }
+ } else {
+ for (const key in data) {
+ extractValues(data[key])
+ }
+ }
+ } else {
+ values.push(data)
+ }
+ }
+
+ extractValues(obj)
+ return values
+}
diff --git a/packages/ui/src/ui-component/button/FlowListMenu.js b/packages/ui/src/ui-component/button/FlowListMenu.js
index b242d2cb..94ecdd01 100644
--- a/packages/ui/src/ui-component/button/FlowListMenu.js
+++ b/packages/ui/src/ui-component/button/FlowListMenu.js
@@ -22,7 +22,6 @@ import useConfirm from 'hooks/useConfirm'
import { uiBaseURL } from '../../store/constant'
import { closeSnackbar as closeSnackbarAction, enqueueSnackbar as enqueueSnackbarAction } from '../../store/actions'
-import ConfirmDialog from '../dialog/ConfirmDialog'
import SaveChatflowDialog from '../dialog/SaveChatflowDialog'
import TagDialog from '../dialog/TagDialog'
@@ -264,7 +263,6 @@ export default function FlowListMenu({ chatflow, updateFlowsApi }) {
Delete
-
{
try {
await chatflowsApi.deleteChatflow(chatflow.id)
localStorage.removeItem(`${chatflow.id}_INTERNAL`)
- navigate(-1)
+ navigate('/')
} catch (error) {
const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}`
enqueueSnackbar({
diff --git a/packages/ui/src/views/chatflows/index.js b/packages/ui/src/views/chatflows/index.js
index 3c4b8972..d91a9cfa 100644
--- a/packages/ui/src/views/chatflows/index.js
+++ b/packages/ui/src/views/chatflows/index.js
@@ -12,6 +12,7 @@ import ItemCard from 'ui-component/cards/ItemCard'
import { gridSpacing } from 'store/constant'
import WorkflowEmptySVG from 'assets/images/workflow_empty.svg'
import LoginDialog from 'ui-component/dialog/LoginDialog'
+import ConfirmDialog from 'ui-component/dialog/ConfirmDialog'
// API
import chatflowsApi from 'api/chatflows'
@@ -212,6 +213,7 @@ const Chatflows = () => {
)}
+
)
}