mirror of https://github.com/langgenius/dify.git
Merge branch 'feat/hitl-frontend' of https://github.com/langgenius/dify into feat/hitl-frontend
This commit is contained in:
commit
ef41325ad1
|
|
@ -34,7 +34,6 @@ const FormContent = ({
|
|||
const [inputs, setInputs] = useState(defaultInputs)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
// use immer
|
||||
const handleInputsChange = (name: string, value: any) => {
|
||||
setInputs(prev => ({
|
||||
...prev,
|
||||
|
|
|
|||
|
|
@ -61,18 +61,28 @@ const useSingleRunFormParams = ({
|
|||
const fetchURL = useMemo(() => {
|
||||
if (!appId)
|
||||
return ''
|
||||
if (isWorkflowMode) {
|
||||
return `/apps/${appId}/advanced-chat/workflows/draft/human_input/nodes/${id}/form`
|
||||
if (!isWorkflowMode) {
|
||||
return `/apps/${appId}/advanced-chat/workflows/draft/human-input/nodes/${id}/form`
|
||||
}
|
||||
else {
|
||||
return `/apps/${appId}/workflows/draft/human_input/nodes/${id}/form`
|
||||
return `/apps/${appId}/workflows/draft/human-input/nodes/${id}/form`
|
||||
}
|
||||
}, [appId, id, isWorkflowMode])
|
||||
|
||||
const handleFetchFormContent = useCallback(async (inputs: Record<string, any>) => {
|
||||
if (!fetchURL)
|
||||
return null
|
||||
const data = await fetchHumanInputNodeStepRunForm(fetchURL, { inputs })
|
||||
let requestParamsObj
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (inputs[key] === undefined) {
|
||||
delete inputs[key]
|
||||
}
|
||||
})
|
||||
requestParamsObj = { ...inputs }
|
||||
if (Object.keys(requestParamsObj).length === 0) {
|
||||
requestParamsObj = undefined
|
||||
}
|
||||
const data = await fetchHumanInputNodeStepRunForm(fetchURL, { inputs: requestParamsObj! })
|
||||
setFormData(data)
|
||||
return data
|
||||
}, [fetchURL])
|
||||
|
|
@ -82,8 +92,8 @@ const useSingleRunFormParams = ({
|
|||
}, [fetchURL])
|
||||
|
||||
const handleShowGeneratedForm = async (formValue: Record<string, any>) => {
|
||||
await handleFetchFormContent(formValue)
|
||||
setShowGeneratedForm(true)
|
||||
await handleFetchFormContent(formValue)
|
||||
}
|
||||
|
||||
const handleHideGeneratedForm = () => {
|
||||
|
|
|
|||
|
|
@ -107,15 +107,15 @@ export const submitHumanInputForm = (token: string, data: {
|
|||
|
||||
export const fetchHumanInputNodeStepRunForm = (
|
||||
url: string,
|
||||
params: {
|
||||
data: {
|
||||
inputs: Record<string, any>
|
||||
},
|
||||
) => {
|
||||
return get<{
|
||||
return post<{
|
||||
form_content: string
|
||||
inputs: FormInputItem[]
|
||||
user_actions: UserAction[]
|
||||
}>(url, { params })
|
||||
}>(`${url}/preview`, { body: data })
|
||||
}
|
||||
|
||||
export const submitHumanInputNodeStepRunForm = (
|
||||
|
|
@ -125,5 +125,5 @@ export const submitHumanInputNodeStepRunForm = (
|
|||
action: string
|
||||
},
|
||||
) => {
|
||||
return post<CommonResponse>(url, { body: data })
|
||||
return post<CommonResponse>(`${url}/run`, { body: data })
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue