mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Merge branch 'main' into feature/lshub-prompt
This commit is contained in:
@@ -558,9 +558,20 @@ export const isStartNodeDependOnInput = (startingNodes: IReactFlowNode[], nodes:
|
|||||||
if (inputVariables.length > 0) return true
|
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) {
|
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
|
return false
|
||||||
}
|
}
|
||||||
@@ -913,3 +924,31 @@ export const replaceChatHistory = async (
|
|||||||
|
|
||||||
return ''
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import useConfirm from 'hooks/useConfirm'
|
|||||||
import { uiBaseURL } from '../../store/constant'
|
import { uiBaseURL } from '../../store/constant'
|
||||||
import { closeSnackbar as closeSnackbarAction, enqueueSnackbar as enqueueSnackbarAction } from '../../store/actions'
|
import { closeSnackbar as closeSnackbarAction, enqueueSnackbar as enqueueSnackbarAction } from '../../store/actions'
|
||||||
|
|
||||||
import ConfirmDialog from '../dialog/ConfirmDialog'
|
|
||||||
import SaveChatflowDialog from '../dialog/SaveChatflowDialog'
|
import SaveChatflowDialog from '../dialog/SaveChatflowDialog'
|
||||||
import TagDialog from '../dialog/TagDialog'
|
import TagDialog from '../dialog/TagDialog'
|
||||||
|
|
||||||
@@ -264,7 +263,6 @@ export default function FlowListMenu({ chatflow, updateFlowsApi }) {
|
|||||||
Delete
|
Delete
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</StyledMenu>
|
</StyledMenu>
|
||||||
<ConfirmDialog />
|
|
||||||
<SaveChatflowDialog
|
<SaveChatflowDialog
|
||||||
show={flowDialogOpen}
|
show={flowDialogOpen}
|
||||||
dialogProps={{
|
dialogProps={{
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ const Canvas = () => {
|
|||||||
try {
|
try {
|
||||||
await chatflowsApi.deleteChatflow(chatflow.id)
|
await chatflowsApi.deleteChatflow(chatflow.id)
|
||||||
localStorage.removeItem(`${chatflow.id}_INTERNAL`)
|
localStorage.removeItem(`${chatflow.id}_INTERNAL`)
|
||||||
navigate(-1)
|
navigate('/')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}`
|
const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}`
|
||||||
enqueueSnackbar({
|
enqueueSnackbar({
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import ItemCard from 'ui-component/cards/ItemCard'
|
|||||||
import { gridSpacing } from 'store/constant'
|
import { gridSpacing } from 'store/constant'
|
||||||
import WorkflowEmptySVG from 'assets/images/workflow_empty.svg'
|
import WorkflowEmptySVG from 'assets/images/workflow_empty.svg'
|
||||||
import LoginDialog from 'ui-component/dialog/LoginDialog'
|
import LoginDialog from 'ui-component/dialog/LoginDialog'
|
||||||
|
import ConfirmDialog from 'ui-component/dialog/ConfirmDialog'
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import chatflowsApi from 'api/chatflows'
|
import chatflowsApi from 'api/chatflows'
|
||||||
@@ -212,6 +213,7 @@ const Chatflows = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
<LoginDialog show={loginDialogOpen} dialogProps={loginDialogProps} onConfirm={onLoginClick} />
|
<LoginDialog show={loginDialogOpen} dialogProps={loginDialogProps} onConfirm={onLoginClick} />
|
||||||
|
<ConfirmDialog />
|
||||||
</MainCard>
|
</MainCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user