mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
Parse human input extra contents by payload
This commit is contained in:
parent
29cad80e62
commit
b879748ba0
@ -1076,6 +1076,10 @@ describe('useChatWithHistory', () => {
|
||||
await waitFor(() => {
|
||||
expect(result!.current.appPrevChatTree.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
const answerNode = result!.current.appPrevChatTree[0]?.children?.[0]
|
||||
expect(answerNode?.humanInputFormDataList).toHaveLength(1)
|
||||
expect(answerNode?.workflow_run_id).toBe('wf-run-1')
|
||||
})
|
||||
|
||||
it('should set workflow_run_id for normal messages with submitted human_input', async () => {
|
||||
@ -1114,6 +1118,9 @@ describe('useChatWithHistory', () => {
|
||||
await waitFor(() => {
|
||||
expect(result!.current.appPrevChatTree.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
const answerNode = result!.current.appPrevChatTree[0]?.children?.[0]
|
||||
expect(answerNode?.humanInputFilledFormDataList).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should return empty appPrevChatTree when there is no currentConversationId', async () => {
|
||||
@ -1835,6 +1842,15 @@ describe('useChatWithHistory', () => {
|
||||
expect(messageWithFiles?.message_files).toHaveLength(1)
|
||||
expect(messageWithFiles?.children?.[0]?.message_files).toHaveLength(1)
|
||||
expect(messageWithFiles?.children?.[0]?.agent_thoughts?.[0]?.message_files).toHaveLength(1)
|
||||
|
||||
const normalAnswerNode = messageWithFiles?.children?.[0]
|
||||
const pausedAnswerNode = result!.current.appPrevChatTree.find(item => item.id === 'question-msg-paused-branch')?.children?.[0]
|
||||
|
||||
expect(normalAnswerNode?.humanInputFilledFormDataList).toHaveLength(1)
|
||||
expect(normalAnswerNode?.humanInputFormDataList).toHaveLength(0)
|
||||
expect(pausedAnswerNode?.humanInputFormDataList).toHaveLength(1)
|
||||
expect(pausedAnswerNode?.humanInputFilledFormDataList).toHaveLength(0)
|
||||
expect(pausedAnswerNode?.workflow_run_id).toBe('wf-run-branch')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -36,21 +36,22 @@ function getFormattedChatList(messages: any[]) {
|
||||
const humanInputFormDataList: HumanInputFormData[] = []
|
||||
const humanInputFilledFormDataList: HumanInputFilledFormData[] = []
|
||||
let workflowRunId = ''
|
||||
if (item.status === 'paused') {
|
||||
item.extra_contents?.forEach((content: ExtraContent) => {
|
||||
if (content.type === 'human_input' && !content.submitted) {
|
||||
humanInputFormDataList.push(content.form_definition)
|
||||
workflowRunId = content.workflow_run_id
|
||||
}
|
||||
})
|
||||
}
|
||||
else if (item.status === 'normal') {
|
||||
item.extra_contents?.forEach((content: ExtraContent) => {
|
||||
if (content.type === 'human_input' && content.submitted) {
|
||||
humanInputFilledFormDataList.push(content.form_submission_data)
|
||||
}
|
||||
})
|
||||
}
|
||||
item.extra_contents?.forEach((content: ExtraContent) => {
|
||||
if (content.type !== 'human_input')
|
||||
return
|
||||
|
||||
if (!content.submitted) {
|
||||
if (!('form_definition' in content) || !content.form_definition)
|
||||
return
|
||||
humanInputFormDataList.push(content.form_definition)
|
||||
workflowRunId = content.workflow_run_id || workflowRunId
|
||||
return
|
||||
}
|
||||
|
||||
if (!('form_submission_data' in content) || !content.form_submission_data)
|
||||
return
|
||||
humanInputFilledFormDataList.push(content.form_submission_data)
|
||||
})
|
||||
newChatList.push({
|
||||
id: item.id,
|
||||
content: item.answer,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user