knowledge base node

This commit is contained in:
zxhlyh
2025-04-25 17:24:47 +08:00
parent 076924bbd6
commit 4792ca1813
32 changed files with 680 additions and 3 deletions

View File

@ -0,0 +1,21 @@
import type { NodeDefault } from '../../types'
import type { KnowledgeBaseNodeType } from './types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
import { BlockEnum } from '@/app/components/workflow/types'
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
...genNodeMetaData({
sort: 3.1,
type: BlockEnum.KnowledgeBase,
}),
defaultValue: {
},
checkValid() {
return {
isValid: true,
errorMessage: '',
}
},
}
export default nodeDefault

View File

@ -0,0 +1,19 @@
import {
useCallback,
useRef,
} from 'react'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import type { KnowledgeBaseNodeType } from '../types'
export const useConfig = (id: string, payload: KnowledgeBaseNodeType) => {
const {
inputs,
setInputs,
} = useNodeCrud(id, payload)
const ref = useRef(inputs)
const handleInputsChange = useCallback((newInputs: KnowledgeBaseNodeType) => {
setInputs(newInputs)
ref.current = newInputs
}, [setInputs, ref])
}

View File

@ -0,0 +1,13 @@
import type { FC } from 'react'
import { memo } from 'react'
import type { KnowledgeBaseNodeType } from './types'
import type { NodeProps } from '@/app/components/workflow/types'
const Node: FC<NodeProps<KnowledgeBaseNodeType>> = () => {
return (
<div className='mb-1 px-3 py-1'>
KnowledgeBase
</div>
)
}
export default memo(Node)

View File

@ -0,0 +1,14 @@
import type { FC } from 'react'
import { memo } from 'react'
import type { KnowledgeBaseNodeType } from './types'
import type { NodePanelProps } from '@/app/components/workflow/types'
const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = () => {
return (
<div className='mb-2 mt-2 space-y-4 px-4'>
Knowledge Base
</div>
)
}
export default memo(Panel)

View File

@ -0,0 +1,3 @@
import type { CommonNodeType } from '@/app/components/workflow/types'
export type KnowledgeBaseNodeType = CommonNodeType