mirror of https://github.com/langgenius/dify.git
feat: template transform
This commit is contained in:
parent
cedc1bada2
commit
1653e5eebe
|
|
@ -5,7 +5,7 @@ import type { CommonNodeType, InputVar, Variable } from '@/app/components/workfl
|
|||
import { InputVarType, NodeRunningStatus } from '@/app/components/workflow/types'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import { singleNodeRun } from '@/service/workflow'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
// import Toast from '@/app/components/base/toast'
|
||||
|
||||
type Params<T> = {
|
||||
id: string
|
||||
|
|
@ -51,10 +51,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
|
|||
throw new Error(res.error)
|
||||
}
|
||||
catch (e: any) {
|
||||
Toast.notify({
|
||||
type: 'error',
|
||||
message: e.toString(),
|
||||
})
|
||||
// Toast.notify({
|
||||
// type: 'error',
|
||||
// message: e.toString(),
|
||||
// })
|
||||
handleNodeDataUpdate({
|
||||
id,
|
||||
data: {
|
||||
|
|
@ -65,7 +65,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
|
|||
return false
|
||||
}
|
||||
finally {
|
||||
setRunResult(res)
|
||||
setRunResult({
|
||||
...res,
|
||||
created_by: res.created_by_account?.name || '',
|
||||
})
|
||||
}
|
||||
handleNodeDataUpdate({
|
||||
id,
|
||||
|
|
@ -74,10 +77,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
|
|||
_singleRunningStatus: NodeRunningStatus.Succeeded,
|
||||
},
|
||||
})
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: t('common.api.success'),
|
||||
})
|
||||
// Toast.notify({
|
||||
// type: 'success',
|
||||
// message: t('common.api.success'),
|
||||
// })
|
||||
}
|
||||
|
||||
const handleStop = () => {
|
||||
|
|
|
|||
|
|
@ -43,22 +43,13 @@ const useConfig = (id: string, payload: CodeNodeType) => {
|
|||
handleStop,
|
||||
runInputData,
|
||||
setRunInputData,
|
||||
runResult: unformattedRunResult,
|
||||
runResult,
|
||||
} = useOneStepRun<CodeNodeType>({
|
||||
id,
|
||||
data: inputs,
|
||||
defaultRunInputData: {},
|
||||
})
|
||||
|
||||
const runResult = (() => {
|
||||
if (!unformattedRunResult)
|
||||
return {}
|
||||
|
||||
return {
|
||||
...unformattedRunResult,
|
||||
created_by: unformattedRunResult.created_by_account?.name || '',
|
||||
}
|
||||
})()
|
||||
const varInputs = toVarInputs(inputs.variables)
|
||||
|
||||
const inputVarValues = (() => {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/compo
|
|||
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form'
|
||||
import ResultPanel from '@/app/components/workflow/run/result-panel'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.templateTransform'
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
|
|||
varInputs,
|
||||
inputVarValues,
|
||||
setInputVarValues,
|
||||
runResult,
|
||||
} = useConfig(id, data)
|
||||
|
||||
return (
|
||||
|
|
@ -105,6 +107,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
|
|||
runningStatus={runningStatus}
|
||||
onRun={handleRun}
|
||||
onStop={handleStop}
|
||||
result={<ResultPanel {...runResult} showSteps={false} />}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
|
|||
handleStop,
|
||||
runInputData,
|
||||
setRunInputData,
|
||||
runResult,
|
||||
} = useOneStepRun<TemplateTransformNodeType>({
|
||||
id,
|
||||
data: inputs,
|
||||
|
|
@ -63,6 +64,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
|
|||
varInputs,
|
||||
inputVarValues,
|
||||
setInputVarValues,
|
||||
runResult,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue