mirror of https://github.com/langgenius/dify.git
feat: add human input output structure and enhance filtering in human input form components
This commit is contained in:
parent
ebb816b90b
commit
d3299db915
|
|
@ -41,10 +41,14 @@ const HumanInputFormList = ({
|
|||
}, {} as Record<string, { showEmailTip: boolean, isEmailDebugMode: boolean, showDebugModeTip: boolean }>)
|
||||
}, [getHumanInputNodeData, humanInputFormDataList])
|
||||
|
||||
const filteredHumanInputFormDataList = useMemo(() => {
|
||||
return humanInputFormDataList.filter(formData => formData.display_in_ui)
|
||||
}, [humanInputFormDataList])
|
||||
|
||||
return (
|
||||
<div className="mt-2 flex flex-col gap-y-2">
|
||||
{
|
||||
humanInputFormDataList.map(formData => (
|
||||
filteredHumanInputFormDataList.map(formData => (
|
||||
<ContentWrapper
|
||||
key={formData.node_id}
|
||||
nodeTitle={formData.node_title}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,17 @@ export const TOOL_OUTPUT_STRUCT: Var[] = [
|
|||
},
|
||||
]
|
||||
|
||||
export const HUMAN_INPUT_OUTPUT_STRUCT: Var[] = [
|
||||
{
|
||||
variable: '__action_id',
|
||||
type: VarType.string,
|
||||
},
|
||||
{
|
||||
variable: '__rendered_content',
|
||||
type: VarType.string,
|
||||
},
|
||||
]
|
||||
|
||||
export const PARAMETER_EXTRACTOR_COMMON_STRUCT: Var[] = [
|
||||
{
|
||||
variable: '__is_success',
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import {
|
|||
FILE_STRUCT,
|
||||
getGlobalVars,
|
||||
HTTP_REQUEST_OUTPUT_STRUCT,
|
||||
HUMAN_INPUT_OUTPUT_STRUCT,
|
||||
KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT,
|
||||
LLM_OUTPUT_STRUCT,
|
||||
PARAMETER_EXTRACTOR_COMMON_STRUCT,
|
||||
|
|
@ -640,7 +641,7 @@ const formatItem = (
|
|||
[],
|
||||
{ schemaTypeDefinitions },
|
||||
) || []
|
||||
res.vars = outputSchema
|
||||
res.vars = [...outputSchema, ...HUMAN_INPUT_OUTPUT_STRUCT]
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const Node: FC<NodeProps<HumanInputNodeType>> = (props) => {
|
|||
<div className="system-xs-semibold-uppercase truncate text-text-secondary">Timeout</div>
|
||||
<NodeSourceHandle
|
||||
{...props}
|
||||
handleId="timeout"
|
||||
handleId="__timeout"
|
||||
handleClassName="!top-1/2 !-right-[9px] !-translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -205,6 +205,16 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
|||
/>
|
||||
))
|
||||
}
|
||||
<VarItem
|
||||
name="__action_id"
|
||||
type="string"
|
||||
description="Action ID user triggered"
|
||||
/>
|
||||
<VarItem
|
||||
name="__rendered_content"
|
||||
type="string"
|
||||
description="Rendered content"
|
||||
/>
|
||||
</OutputVars>
|
||||
|
||||
{isPreview && (
|
||||
|
|
|
|||
|
|
@ -52,10 +52,14 @@ const HumanInputFormList = ({
|
|||
}, {} as Record<string, { showEmailTip: boolean, isEmailDebugMode: boolean, showDebugModeTip: boolean }>)
|
||||
}, [getHumanInputNodeData, humanInputFormDataList])
|
||||
|
||||
const filteredHumanInputFormDataList = useMemo(() => {
|
||||
return humanInputFormDataList.filter(formData => formData.display_in_ui)
|
||||
}, [humanInputFormDataList])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-y-3">
|
||||
{
|
||||
humanInputFormDataList.map(formData => (
|
||||
filteredHumanInputFormDataList.map(formData => (
|
||||
<ContentWrapper
|
||||
key={formData.node_id}
|
||||
nodeTitle={formData.node_title}
|
||||
|
|
|
|||
|
|
@ -334,12 +334,12 @@ export const getHumanInputForm = (token: string) => {
|
|||
inputs: FormInputItem[]
|
||||
user_actions: UserAction[]
|
||||
expiration_time: number
|
||||
}>(`/api/form/human_input/${token}`)
|
||||
}>(`/form/human_input/${token}`)
|
||||
}
|
||||
|
||||
export const submitHumanInputForm = (token: string, data: {
|
||||
inputs: Record<string, any>
|
||||
action: string
|
||||
}) => {
|
||||
return post(`/api/form/human_input/${token}`, { body: data })
|
||||
return post(`/form/human_input/${token}`, { body: data })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,8 @@ export type HumanInputFormData = {
|
|||
inputs: FormInputItem[]
|
||||
actions: UserAction[]
|
||||
form_token: string
|
||||
resolved_placeholder_values: Record<string, string> // For human input placeholder when its type is variable
|
||||
resolved_placeholder_values: Record<string, string>
|
||||
display_in_ui: boolean
|
||||
}
|
||||
|
||||
export type HumanInputRequiredResponse = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue