block selector & data source node
parent
efb27eb443
commit
8d9c252811
@ -0,0 +1,27 @@
|
|||||||
|
import { BlockEnum } from '../../types'
|
||||||
|
import type { NodeDefault } from '../../types'
|
||||||
|
import type { DataSourceNodeType } from './types'
|
||||||
|
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||||
|
|
||||||
|
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||||
|
defaultValue: {
|
||||||
|
},
|
||||||
|
getAvailablePrevNodes(isChatMode: boolean) {
|
||||||
|
const nodes = isChatMode
|
||||||
|
? ALL_CHAT_AVAILABLE_BLOCKS
|
||||||
|
: ALL_COMPLETION_AVAILABLE_BLOCKS.filter(type => type !== BlockEnum.End)
|
||||||
|
return nodes
|
||||||
|
},
|
||||||
|
getAvailableNextNodes(isChatMode: boolean) {
|
||||||
|
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||||
|
return nodes
|
||||||
|
},
|
||||||
|
checkValid() {
|
||||||
|
return {
|
||||||
|
isValid: true,
|
||||||
|
errorMessage: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default nodeDefault
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import type { FC } from 'react'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import type { DataSourceNodeType } from './types'
|
||||||
|
import type { NodeProps } from '@/app/components/workflow/types'
|
||||||
|
const Node: FC<NodeProps<DataSourceNodeType>> = () => {
|
||||||
|
return (
|
||||||
|
<div className='mb-1 px-3 py-1'>
|
||||||
|
DataSource
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memo(Node)
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import type { FC } from 'react'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import type { DataSourceNodeType } from './types'
|
||||||
|
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
const Panel: FC<NodePanelProps<DataSourceNodeType>> = () => {
|
||||||
|
return (
|
||||||
|
<div className='mb-2 mt-2 space-y-4 px-4'>
|
||||||
|
datasource
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memo(Panel)
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import type { CommonNodeType } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
export type DataSourceNodeType = CommonNodeType
|
||||||
Loading…
Reference in New Issue