diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.ts index fc94c3003c..1091299628 100644 --- a/web/app/components/workflow/constants.ts +++ b/web/app/components/workflow/constants.ts @@ -117,3 +117,23 @@ export const NODE_WIDTH = 220 export const X_OFFSET = 64 export const Y_OFFSET = 39 export const TREE_DEEPTH = 20 + +export const RETRIEVAL_OUTPUT_STRUCT = `{ + "content": "", + "title": "", + "url": "", + "icon": "", + "metadata": { + "dataset_id": "", + "dataset_name": "", + "document_id": [], + "document_name": "", + "document_data_source_type": "", + "segment_id": "", + "segment_position": "", + "segment_word_count": "", + "segment_hit_count": "", + "segment_index_node_hash": "", + "score": "" + } +}` diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx new file mode 100644 index 0000000000..5ade9dbe41 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx @@ -0,0 +1,137 @@ +'use client' +import type { FC } from 'react' +import React, { useCallback } from 'react' +import produce from 'immer' +import type { InputVar } from '../../../../types' +import { InputVarType } from '../../../../types' +import CodeEditor from '../editor/code-editor' +import { CodeLanguage } from '../../../code/types' +import Select from '@/app/components/base/select' +import TextGenerationImageUploader from '@/app/components/base/image-uploader/text-generation-image-uploader' +import { Resolution, TransferMethod } from '@/types/app' +import { Trash03 } from '@/app/components/base/icons/src/vender/line/general' + +type Props = { + payload: InputVar + value: any + onChange: (value: any) => void +} + +const FormItem: FC = ({ + payload, + value, + onChange, +}) => { + const { type } = payload + const handleContextItemChange = useCallback((index: number) => { + return (newValue: any) => { + const newValues = produce(value, (draft: any) => { + draft[index] = newValue + }) + onChange(newValues) + } + }, [value, onChange]) + + const handleContextItemRemove = useCallback((index: number) => { + return () => { + const newValues = produce(value, (draft: any) => { + draft.splice(index, 1) + }) + onChange(newValues) + } + }, [value, onChange]) + return ( +
+ {type !== InputVarType.contexts &&
{payload.label}
} +
+ { + type === InputVarType.textInput && ( + onChange(e.target.value)} + /> + ) + } + + { + type === InputVarType.number && ( + onChange(e.target.value)} + /> + ) + } + + { + type === InputVarType.paragraph && ( +