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