mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
@@ -2,25 +2,18 @@ import { uniq } from 'lodash'
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
export const getUniqueNodeId = (nodeData, nodes) => {
|
export const getUniqueNodeId = (nodeData, nodes) => {
|
||||||
// Get amount of same nodes
|
let suffix = 0
|
||||||
let totalSameNodes = 0
|
|
||||||
for (let i = 0; i < nodes.length; i += 1) {
|
// Construct base ID
|
||||||
const node = nodes[i]
|
let baseId = `${nodeData.name}_${suffix}`
|
||||||
if (node.data.name === nodeData.name) {
|
|
||||||
totalSameNodes += 1
|
// Increment suffix until a unique ID is found
|
||||||
}
|
while (nodes.some((node) => node.id === baseId)) {
|
||||||
|
suffix += 1
|
||||||
|
baseId = `${nodeData.name}_${suffix}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get unique id
|
return baseId
|
||||||
let nodeId = `${nodeData.name}_${totalSameNodes}`
|
|
||||||
for (let i = 0; i < nodes.length; i += 1) {
|
|
||||||
const node = nodes[i]
|
|
||||||
if (node.id === nodeId) {
|
|
||||||
totalSameNodes += 1
|
|
||||||
nodeId = `${nodeData.name}_${totalSameNodes}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nodeId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initializeDefaultNodeData = (nodeParams) => {
|
export const initializeDefaultNodeData = (nodeParams) => {
|
||||||
|
|||||||
@@ -54,9 +54,16 @@ function a11yProps(index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const blacklistCategoriesForAgentCanvas = ['Agents', 'Memory', 'Record Manager']
|
const blacklistCategoriesForAgentCanvas = ['Agents', 'Memory', 'Record Manager', 'Utilities']
|
||||||
const allowedAgentModel = {}
|
|
||||||
const exceptions = {
|
// Show blacklisted nodes (exceptions) for agent canvas
|
||||||
|
const exceptionsForAgentCanvas = {
|
||||||
|
Memory: ['agentMemory'],
|
||||||
|
Utilities: ['getVariable', 'setVariable', 'stickyNote']
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide some nodes from the chatflow canvas
|
||||||
|
const blacklistForChatflowCanvas = {
|
||||||
Memory: ['agentMemory']
|
Memory: ['agentMemory']
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,11 +94,16 @@ const AddNodes = ({ nodesData, node, isAgentCanvas }) => {
|
|||||||
filterSearch(searchValue, newValue)
|
filterSearch(searchValue, newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
const addException = () => {
|
const addException = (category) => {
|
||||||
let nodes = []
|
let nodes = []
|
||||||
for (const category in exceptions) {
|
if (category) {
|
||||||
const nodeNames = exceptions[category]
|
const nodeNames = exceptionsForAgentCanvas[category] || []
|
||||||
nodes.push(...nodesData.filter((nd) => nd.category === category && nodeNames.includes(nd.name)))
|
nodes = nodesData.filter((nd) => nd.category === category && nodeNames.includes(nd.name))
|
||||||
|
} else {
|
||||||
|
for (const category in exceptionsForAgentCanvas) {
|
||||||
|
const nodeNames = exceptionsForAgentCanvas[category]
|
||||||
|
nodes.push(...nodesData.filter((nd) => nd.category === category && nodeNames.includes(nd.name)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
@@ -108,7 +120,13 @@ const AddNodes = ({ nodesData, node, isAgentCanvas }) => {
|
|||||||
})
|
})
|
||||||
return passed
|
return passed
|
||||||
}
|
}
|
||||||
const nodes = nodesData.filter((nd) => nd.category !== 'Multi Agents' && nd.category !== 'Sequential Agents')
|
let nodes = nodesData.filter((nd) => nd.category !== 'Multi Agents' && nd.category !== 'Sequential Agents')
|
||||||
|
|
||||||
|
for (const category in blacklistForChatflowCanvas) {
|
||||||
|
const nodeNames = blacklistForChatflowCanvas[category]
|
||||||
|
nodes = nodes.filter((nd) => !nodeNames.includes(nd.name))
|
||||||
|
}
|
||||||
|
|
||||||
const passed = nodes.filter((nd) => {
|
const passed = nodes.filter((nd) => {
|
||||||
const passesName = nd.name.toLowerCase().includes(value.toLowerCase())
|
const passesName = nd.name.toLowerCase().includes(value.toLowerCase())
|
||||||
const passesLabel = nd.label.toLowerCase().includes(value.toLowerCase())
|
const passesLabel = nd.label.toLowerCase().includes(value.toLowerCase())
|
||||||
@@ -163,18 +181,12 @@ const AddNodes = ({ nodesData, node, isAgentCanvas }) => {
|
|||||||
const nodes = result[category].filter((nd) => !nd.tags || !nd.tags.includes('LlamaIndex'))
|
const nodes = result[category].filter((nd) => !nd.tags || !nd.tags.includes('LlamaIndex'))
|
||||||
if (!nodes.length) continue
|
if (!nodes.length) continue
|
||||||
|
|
||||||
// Only allow specific models for specific categories
|
filteredResult[category] = nodes
|
||||||
if (Object.keys(allowedAgentModel).includes(category)) {
|
|
||||||
const allowedModels = allowedAgentModel[category]
|
|
||||||
filteredResult[category] = nodes.filter((nd) => allowedModels.includes(nd.name))
|
|
||||||
} else {
|
|
||||||
filteredResult[category] = nodes
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow exceptions
|
// Allow exceptionsForAgentCanvas
|
||||||
if (Object.keys(exceptions).includes(category)) {
|
if (Object.keys(exceptionsForAgentCanvas).includes(category)) {
|
||||||
filteredResult[category] = addException()
|
filteredResult[category] = addException(category)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setNodes(filteredResult)
|
setNodes(filteredResult)
|
||||||
@@ -197,8 +209,13 @@ const AddNodes = ({ nodesData, node, isAgentCanvas }) => {
|
|||||||
if (category === 'Multi Agents' || category === 'Sequential Agents') {
|
if (category === 'Multi Agents' || category === 'Sequential Agents') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if (Object.keys(blacklistForChatflowCanvas).includes(category)) {
|
||||||
|
const nodes = blacklistForChatflowCanvas[category]
|
||||||
|
result[category] = result[category].filter((nd) => !nodes.includes(nd.name))
|
||||||
|
}
|
||||||
filteredResult[category] = result[category]
|
filteredResult[category] = result[category]
|
||||||
}
|
}
|
||||||
|
|
||||||
setNodes(filteredResult)
|
setNodes(filteredResult)
|
||||||
setCategoryExpanded(accordianCategories)
|
setCategoryExpanded(accordianCategories)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user