datasource panel
parent
5aaa06c8b0
commit
7d92574e02
@ -1,5 +1,34 @@
|
||||
import { useCallback } from 'react'
|
||||
import { useStoreApi } from 'reactflow'
|
||||
import { useNodeDataUpdate } from '@/app/components/workflow/hooks'
|
||||
import type { DataSourceNodeType } from '../types'
|
||||
|
||||
export const useConfig = (id: string) => {
|
||||
return {
|
||||
const store = useStoreApi()
|
||||
const { handleNodeDataUpdateWithSyncDraft } = useNodeDataUpdate()
|
||||
|
||||
const getNodeData = useCallback(() => {
|
||||
const { getNodes } = store.getState()
|
||||
const nodes = getNodes()
|
||||
|
||||
return nodes.find(node => node.id === id)
|
||||
}, [store, id])
|
||||
|
||||
const handleNodeDataUpdate = useCallback((data: Partial<DataSourceNodeType>) => {
|
||||
handleNodeDataUpdateWithSyncDraft({
|
||||
id,
|
||||
data,
|
||||
})
|
||||
}, [id, handleNodeDataUpdateWithSyncDraft])
|
||||
const handleFileExtensionsChange = useCallback((fileExtensions: string[]) => {
|
||||
const nodeData = getNodeData()
|
||||
handleNodeDataUpdate({
|
||||
...nodeData?.data,
|
||||
fileExtensions,
|
||||
})
|
||||
}, [handleNodeDataUpdate, getNodeData])
|
||||
|
||||
return {
|
||||
handleFileExtensionsChange,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import type { CommonNodeType } from '@/app/components/workflow/types'
|
||||
import type { RAGPipelineVariables } from '@/models/pipeline'
|
||||
import type { CollectionType } from '@/app/components/tools/types'
|
||||
|
||||
export type DataSourceNodeType = CommonNodeType & {
|
||||
variables: RAGPipelineVariables
|
||||
output_schema: Record<string, any>
|
||||
provider_id: string
|
||||
provider_type: CollectionType
|
||||
fileExtensions?: string[]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue