mirror of
https://github.com/langgenius/dify.git
synced 2025-12-27 18:12:29 +00:00
node default configs
This commit is contained in:
parent
5c228bca4f
commit
26aff400e4
@ -9,7 +9,10 @@ import type { CodeNodeType, OutputVar } from './types'
|
||||
import { CodeLanguage } from './types'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
|
||||
import { fetchNodeDefault } from '@/service/workflow'
|
||||
import {
|
||||
fetchNodeDefault,
|
||||
fetchPipelineNodeDefault,
|
||||
} from '@/service/workflow'
|
||||
import {
|
||||
useNodesReadOnly,
|
||||
} from '@/app/components/workflow/hooks'
|
||||
@ -18,6 +21,7 @@ const useConfig = (id: string, payload: CodeNodeType) => {
|
||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||
|
||||
const appId = useStore(s => s.appId)
|
||||
const pipelineId = useStore(s => s.pipelineId)
|
||||
|
||||
const [allLanguageDefault, setAllLanguageDefault] = useState<Record<CodeLanguage, CodeNodeType> | null>(null)
|
||||
useEffect(() => {
|
||||
@ -33,6 +37,19 @@ const useConfig = (id: string, payload: CodeNodeType) => {
|
||||
}
|
||||
}, [appId])
|
||||
|
||||
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>({
|
||||
|
||||
@ -59,6 +59,12 @@ export const fetchNodeDefault = (appId: string, blockType: BlockEnum, query = {}
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchPipelineNodeDefault = (pipelineId: string, blockType: BlockEnum, query = {}) => {
|
||||
return get(`rag/pipelines/${pipelineId}/workflows/default-workflow-block-configs/${blockType}`, {
|
||||
params: { q: JSON.stringify(query) },
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: archived
|
||||
export const updateWorkflowDraftFromDSL = (appId: string, data: string) => {
|
||||
return post<FetchWorkflowDraftResponse>(`apps/${appId}/workflows/draft/import`, { body: { data } })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user