diff --git a/web/app/components/workflow/block-selector/constants.ts b/web/app/components/workflow/block-selector/constants.ts new file mode 100644 index 0000000000..85b2ac69b8 --- /dev/null +++ b/web/app/components/workflow/block-selector/constants.ts @@ -0,0 +1,80 @@ +export const TABS = [ + { + key: 'blocks', + name: 'Blocks', + }, + { + key: 'built-in-tool', + name: 'Built-in Tool', + }, + { + key: 'custom-tool', + name: 'Custom Tool', + }, +] + +export const BLOCKS = [ + { + type: 'start', + title: 'Start', + description: '', + icon: '', + }, + { + type: 'llm', + title: 'LLM', + icon: '', + }, + { + type: 'end', + title: 'End', + icon: '', + }, + { + type: 'direct-answer', + title: 'Direct Answer', + icon: '', + }, + { + classification: 'Question Understand', + type: 'knowledge-retrieval', + title: 'Knowledge Retrieval', + icon: '', + }, + { + classification: 'Question Understand', + type: 'question-classifier', + title: 'Question Classifier', + icon: '', + }, + { + classification: 'Logic', + type: 'if-else', + title: 'IF/ELSE', + icon: '', + }, + { + classification: 'Transform', + type: 'code', + title: 'Code', + icon: '', + }, + { + classification: 'Transform', + type: 'template-transform', + title: 'Templating Transform', + icon: '', + }, + { + classification: 'Transform', + type: 'variable-assigner', + title: 'Variable Assigner', + icon: '', + }, + { + classification: 'Utilities', + type: 'http-request', + title: 'HTTP Request', + icon: '', + }, +] diff --git a/web/app/components/workflow/block-selector/index.tsx b/web/app/components/workflow/block-selector/index.tsx new file mode 100644 index 0000000000..b946d0f91f --- /dev/null +++ b/web/app/components/workflow/block-selector/index.tsx @@ -0,0 +1,54 @@ +import type { FC, ReactElement } from 'react' +import { + memo, + useCallback, + useState, +} from 'react' +import Tabs from './tabs' +import { + PortalToFollowElem, + PortalToFollowElemContent, + PortalToFollowElemTrigger, +} from '@/app/components/base/portal-to-follow-elem' +import { SearchLg } from '@/app/components/base/icons/src/vender/line/general' + +type NodeSelectorProps = { + children: ReactElement +} +const NodeSelector: FC = ({ + children, +}) => { + const [open, setOpen] = useState(false) + const handleTrigger: any = useCallback((e: MouseEvent) => { + e.stopPropagation() + setOpen(v => !v) + }, []) + + return ( + + + {children} + + +
+
+
+ + +
+
+ +
+
+
+ ) +} + +export default memo(NodeSelector) diff --git a/web/app/components/workflow/block-selector/tabs.tsx b/web/app/components/workflow/block-selector/tabs.tsx new file mode 100644 index 0000000000..42919813af --- /dev/null +++ b/web/app/components/workflow/block-selector/tabs.tsx @@ -0,0 +1,45 @@ +import { useState } from 'react' +import { + BLOCKS, + TABS, +} from './constants' + +const Tabs = () => { + const [activeTab, setActiveTab] = useState(TABS[0].key) + + return ( +
+
+ { + TABS.map(tab => ( +
setActiveTab(tab.key)} + > + {tab.name} +
+ )) + } +
+
+ { + BLOCKS.map(block => ( +
+
+
{block.title}
+
+ )) + } +
+
+ ) +} + +export default Tabs diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx index a348fd29c3..7ab926b205 100644 --- a/web/app/components/workflow/nodes/_base/node.tsx +++ b/web/app/components/workflow/nodes/_base/node.tsx @@ -8,6 +8,7 @@ import { useNodeId, } from 'reactflow' import { useWorkflowContext } from '../../context' +import BlockSelector from '../../block-selector' import { Plus } from '@/app/components/base/icons/src/vender/line/general' type BaseNodeProps = { @@ -48,15 +49,17 @@ const BaseNode: FC = ({
Define the initial parameters for launching a workflow
- + + +
) }