mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 16:55:57 +08:00
feat: no data running
This commit is contained in:
parent
ae0657dd02
commit
6caf6714cd
@ -127,15 +127,8 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
|
|||||||
|
|
||||||
const submitData: Record<string, any> = {}
|
const submitData: Record<string, any> = {}
|
||||||
let parseErrorJsonField = ''
|
let parseErrorJsonField = ''
|
||||||
forms.forEach((form, i) => {
|
forms.forEach((form) => {
|
||||||
const existVarValuesInForm = existVarValuesInForms[i]
|
|
||||||
|
|
||||||
form.inputs.forEach((input) => {
|
form.inputs.forEach((input) => {
|
||||||
if (input.variable in existVarValuesInForm) {
|
|
||||||
// TODO: wait for api if need to pass exist var values
|
|
||||||
submitData[input.variable] = existVarValuesInForm[input.variable]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const value = formatValue(form.values[input.variable], input.type)
|
const value = formatValue(form.values[input.variable], input.type)
|
||||||
submitData[input.variable] = value
|
submitData[input.variable] = value
|
||||||
|
@ -152,7 +152,8 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
singleRunParams,
|
singleRunParams,
|
||||||
setRunInputData,
|
setRunInputData,
|
||||||
hasLastRunData,
|
hasLastRunData,
|
||||||
handleRun,
|
handleSingleRun,
|
||||||
|
handleRunWithParams,
|
||||||
getExistVarValuesInForms,
|
getExistVarValuesInForms,
|
||||||
getFilteredExistVarForms,
|
getFilteredExistVarForms,
|
||||||
} = useLastRun<typeof data>({
|
} = useLastRun<typeof data>({
|
||||||
@ -178,7 +179,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
nodeType={data.type}
|
nodeType={data.type}
|
||||||
onHide={hideSingleRun}
|
onHide={hideSingleRun}
|
||||||
runningStatus={runningStatus}
|
runningStatus={runningStatus}
|
||||||
onRun={handleRun}
|
onRun={handleRunWithParams}
|
||||||
onStop={handleStop}
|
onStop={handleStop}
|
||||||
{...singleRunParams!}
|
{...singleRunParams!}
|
||||||
existVarValuesInForms={getExistVarValuesInForms(singleRunParams?.forms as any)}
|
existVarValuesInForms={getExistVarValuesInForms(singleRunParams?.forms as any)}
|
||||||
@ -228,18 +229,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className='mr-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-md hover:bg-state-base-hover'
|
className='mr-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-md hover:bg-state-base-hover'
|
||||||
onClick={() => {
|
onClick={handleSingleRun}
|
||||||
const filteredExistVarForms = getFilteredExistVarForms(singleRunParams.forms)
|
|
||||||
if (filteredExistVarForms.length > 0) {
|
|
||||||
showSingleRun()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO: check valid
|
|
||||||
// TODO: all value is setted. wait for api if need to pass exist var values
|
|
||||||
handleRun({})
|
|
||||||
}
|
|
||||||
handleSyncWorkflowDraft(true)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<RiPlayLargeLine className='h-4 w-4 text-text-tertiary' />
|
<RiPlayLargeLine className='h-4 w-4 text-text-tertiary' />
|
||||||
</div>
|
</div>
|
||||||
@ -323,7 +313,12 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{tabType === TabType.lastRun && (
|
{tabType === TabType.lastRun && (
|
||||||
<LastRun appId={appDetail?.id || ''} nodeId={id} runningStatus={runningStatus} />
|
<LastRun
|
||||||
|
appId={appDetail?.id || ''}
|
||||||
|
nodeId={id}
|
||||||
|
runningStatus={runningStatus}
|
||||||
|
onSingleRunClicked={handleSingleRun}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,20 +11,18 @@ type Props = {
|
|||||||
appId: string
|
appId: string
|
||||||
nodeId: string
|
nodeId: string
|
||||||
runningStatus?: NodeRunningStatus
|
runningStatus?: NodeRunningStatus
|
||||||
|
onSingleRunClicked: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const LastRun: FC<Props> = ({
|
const LastRun: FC<Props> = ({
|
||||||
appId,
|
appId,
|
||||||
nodeId,
|
nodeId,
|
||||||
runningStatus,
|
runningStatus,
|
||||||
|
onSingleRunClicked,
|
||||||
}) => {
|
}) => {
|
||||||
const isRunning = runningStatus === NodeRunningStatus.Running
|
const isRunning = runningStatus === NodeRunningStatus.Running
|
||||||
const { data: runResult, isFetching } = useLastRun(appId, nodeId, !isRunning)
|
const { data: runResult, isFetching } = useLastRun(appId, nodeId, !isRunning)
|
||||||
|
|
||||||
const handleSingleRun = () => {
|
|
||||||
console.log('run')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFetching)
|
if (isFetching)
|
||||||
return <Loading />
|
return <Loading />
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ const LastRun: FC<Props> = ({
|
|||||||
|
|
||||||
if (!runResult) {
|
if (!runResult) {
|
||||||
return (
|
return (
|
||||||
<NoData onSingleRun={handleSingleRun} />
|
<NoData onSingleRun={onSingleRunClicked} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
@ -6,6 +6,9 @@ import { useWorkflowStore } from '@/app/components/workflow/store'
|
|||||||
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
|
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
|
||||||
import useLLMSingleRunFormParams from '@/app/components/workflow/nodes/llm/use-single-run-form-params'
|
import useLLMSingleRunFormParams from '@/app/components/workflow/nodes/llm/use-single-run-form-params'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
import {
|
||||||
|
useNodesSyncDraft,
|
||||||
|
} from '@/app/components/workflow/hooks'
|
||||||
|
|
||||||
const singleRunFormParamsHooks: Record<BlockEnum, any> = {
|
const singleRunFormParamsHooks: Record<BlockEnum, any> = {
|
||||||
[BlockEnum.LLM]: useLLMSingleRunFormParams,
|
[BlockEnum.LLM]: useLLMSingleRunFormParams,
|
||||||
@ -43,6 +46,8 @@ type Params<T> = OneStepRunParams<T>
|
|||||||
const useLastRun = <T>({
|
const useLastRun = <T>({
|
||||||
...oneStepRunParams
|
...oneStepRunParams
|
||||||
}: Params<T>) => {
|
}: Params<T>) => {
|
||||||
|
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
@ -50,12 +55,13 @@ const useLastRun = <T>({
|
|||||||
const oneStepRunRes = useOneStepRun(oneStepRunParams)
|
const oneStepRunRes = useOneStepRun(oneStepRunParams)
|
||||||
const {
|
const {
|
||||||
hideSingleRun,
|
hideSingleRun,
|
||||||
handleRun: callRunApi,
|
handleRun: doCallRunApi,
|
||||||
getInputVars,
|
getInputVars,
|
||||||
toVarInputs,
|
toVarInputs,
|
||||||
runInputData,
|
runInputData,
|
||||||
runInputDataRef,
|
runInputDataRef,
|
||||||
setRunInputData,
|
setRunInputData,
|
||||||
|
showSingleRun,
|
||||||
} = oneStepRunRes
|
} = oneStepRunRes
|
||||||
|
|
||||||
const singleRunParams = useSingleRunFormParamsHooks(data.type)({
|
const singleRunParams = useSingleRunFormParamsHooks(data.type)({
|
||||||
@ -68,8 +74,13 @@ const useLastRun = <T>({
|
|||||||
toVarInputs,
|
toVarInputs,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const callRunApi = async (data: Record<string, any>) => {
|
||||||
|
await handleSyncWorkflowDraft(true)
|
||||||
|
doCallRunApi(data)
|
||||||
|
}
|
||||||
|
|
||||||
const [tabType, setTabType] = useState<TabType>(TabType.settings)
|
const [tabType, setTabType] = useState<TabType>(TabType.settings)
|
||||||
const handleRun = async (data: Record<string, any>) => {
|
const handleRunWithParams = async (data: Record<string, any>) => {
|
||||||
setTabType(TabType.lastRun)
|
setTabType(TabType.lastRun)
|
||||||
callRunApi(data)
|
callRunApi(data)
|
||||||
hideSingleRun()
|
hideSingleRun()
|
||||||
@ -141,6 +152,14 @@ const useLastRun = <T>({
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSingleRun = () => {
|
||||||
|
const filteredExistVarForms = getFilteredExistVarForms(singleRunParams.forms)
|
||||||
|
if (filteredExistVarForms.length > 0)
|
||||||
|
showSingleRun()
|
||||||
|
else
|
||||||
|
callRunApi({})// no need to pass params
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...oneStepRunRes,
|
...oneStepRunRes,
|
||||||
tabType,
|
tabType,
|
||||||
@ -148,7 +167,8 @@ const useLastRun = <T>({
|
|||||||
singleRunParams,
|
singleRunParams,
|
||||||
setRunInputData,
|
setRunInputData,
|
||||||
hasLastRunData,
|
hasLastRunData,
|
||||||
handleRun,
|
handleSingleRun,
|
||||||
|
handleRunWithParams,
|
||||||
getExistVarValuesInForms,
|
getExistVarValuesInForms,
|
||||||
getFilteredExistVarForms,
|
getFilteredExistVarForms,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user