(startingNodes: IReactFlowNode[], nodes: IReactFlowNode[])
| 1256 | * @returns {boolean} |
| 1257 | */ |
| 1258 | export const isStartNodeDependOnInput = (startingNodes: IReactFlowNode[], nodes: IReactFlowNode[]): boolean => { |
| 1259 | for (const node of startingNodes) { |
| 1260 | if (node.data.category === 'Cache') return true |
| 1261 | for (const inputName in node.data.inputs) { |
| 1262 | const inputVariables = getInputVariables(node.data.inputs[inputName]) |
| 1263 | if (inputVariables.length > 0) return true |
| 1264 | } |
| 1265 | } |
| 1266 | const whitelistNodeNames = ['vectorStoreToDocument', 'autoGPT', 'chatPromptTemplate', 'promptTemplate'] //If these nodes are found, chatflow cannot be reused |
| 1267 | for (const node of nodes) { |
| 1268 | if (node.data.name === 'chatPromptTemplate' || node.data.name === 'promptTemplate') { |
| 1269 | let promptValues: ICommonObject = {} |
| 1270 | const promptValuesRaw = node.data.inputs?.promptValues |
| 1271 | if (promptValuesRaw) { |
| 1272 | try { |
| 1273 | promptValues = typeof promptValuesRaw === 'object' ? promptValuesRaw : JSON.parse(promptValuesRaw) |
| 1274 | } catch (exception) { |
| 1275 | console.error(exception) |
| 1276 | } |
| 1277 | } |
| 1278 | if (getAllValuesFromJson(promptValues).includes(`{{${QUESTION_VAR_PREFIX}}}`)) return true |
| 1279 | } else if (whitelistNodeNames.includes(node.data.name)) return true |
| 1280 | } |
| 1281 | return false |
| 1282 | } |
| 1283 | |
| 1284 | /** |
| 1285 | * Rebuild flow if new override config is provided |
nothing calls this directly
no test coverage detected