feat: knowledge pipeline (#25360)
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: jyong <718720800@qq.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: quicksand <quicksandzn@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Hanqing Zhao <sherry9277@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Harry <xh001x@hotmail.com>
This commit is contained in:
@@ -8,8 +8,10 @@ import { useStore } from '../../store'
|
||||
import type { CodeNodeType, OutputVar } from './types'
|
||||
import { CodeLanguage } from './types'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
import { fetchNodeDefault } from '@/service/workflow'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import {
|
||||
fetchNodeDefault,
|
||||
fetchPipelineNodeDefault,
|
||||
} from '@/service/workflow'
|
||||
import {
|
||||
useNodesReadOnly,
|
||||
} from '@/app/components/workflow/hooks'
|
||||
@@ -17,7 +19,8 @@ import {
|
||||
const useConfig = (id: string, payload: CodeNodeType) => {
|
||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||
|
||||
const appId = useAppStore.getState().appDetail?.id
|
||||
const appId = useStore(s => s.appId)
|
||||
const pipelineId = useStore(s => s.pipelineId)
|
||||
|
||||
const [allLanguageDefault, setAllLanguageDefault] = useState<Record<CodeLanguage, CodeNodeType> | null>(null)
|
||||
useEffect(() => {
|
||||
@@ -33,7 +36,20 @@ const useConfig = (id: string, payload: CodeNodeType) => {
|
||||
}
|
||||
}, [appId])
|
||||
|
||||
const defaultConfig = useStore(s => s.nodesDefaultConfigs)[payload.type]
|
||||
useEffect(() => {
|
||||
if (pipelineId) {
|
||||
(async () => {
|
||||
const { config: javaScriptConfig } = await fetchPipelineNodeDefault(pipelineId, BlockEnum.Code, { code_language: CodeLanguage.javascript }) as any
|
||||
const { config: pythonConfig } = await fetchPipelineNodeDefault(pipelineId, BlockEnum.Code, { code_language: CodeLanguage.python3 }) as any
|
||||
setAllLanguageDefault({
|
||||
[CodeLanguage.javascript]: javaScriptConfig as CodeNodeType,
|
||||
[CodeLanguage.python3]: pythonConfig as CodeNodeType,
|
||||
} as any)
|
||||
})()
|
||||
}
|
||||
}, [pipelineId])
|
||||
|
||||
const defaultConfig = useStore(s => s.nodesDefaultConfigs)?.[payload.type]
|
||||
const { inputs, setInputs } = useNodeCrud<CodeNodeType>(id, payload)
|
||||
const { handleVarListChange, handleAddVariable } = useVarList<CodeNodeType>({
|
||||
inputs,
|
||||
|
||||
Reference in New Issue
Block a user