From 19d3ba42e5b859cdd0192a6505a3a41c4fba8459 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 27 Aug 2025 17:39:43 +0800 Subject: [PATCH] chore: schema type change --- .../nodes/_base/components/variable/utils.ts | 2 +- .../components/variable/var-reference-picker.tsx | 3 +++ .../components/variable/var-reference-popup.tsx | 3 +++ .../components/variable/var-reference-vars.tsx | 12 ++++++++++-- .../workflow/nodes/knowledge-base/panel.tsx | 13 ++++--------- web/app/components/workflow/types.ts | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 5324e94f48..52e18ef10e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -221,7 +221,7 @@ const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: Val variable: obj.variable, type: isFile ? VarType.file : VarType.object, children: childrenResult, - alias: obj.alias, + schemaType: obj.schemaType, } return res diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx index 0816da164a..b90fd53125 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx @@ -79,6 +79,7 @@ type Props = { zIndex?: number currentTool?: Tool currentProvider?: ToolWithProvider + preferSchemaType?: boolean } const DEFAULT_VALUE_SELECTOR: Props['value'] = [] @@ -111,6 +112,7 @@ const VarReferencePicker: FC = ({ zIndex, currentTool, currentProvider, + preferSchemaType, }) => { const { t } = useTranslation() const store = useStoreApi() @@ -562,6 +564,7 @@ const VarReferencePicker: FC = ({ itemWidth={isAddBtnTrigger ? 260 : (minWidth || triggerWidth)} isSupportFileVar={isSupportFileVar} zIndex={zIndex} + preferSchemaType={preferSchemaType} /> )} diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx index 5fefb74fcb..5f68bcbf0c 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx @@ -15,6 +15,7 @@ type Props = { itemWidth?: number isSupportFileVar?: boolean zIndex?: number + preferSchemaType?: boolean } const VarReferencePopup: FC = ({ vars, @@ -23,6 +24,7 @@ const VarReferencePopup: FC = ({ itemWidth, isSupportFileVar = true, zIndex, + preferSchemaType, }) => { const { t } = useTranslation() const pipelineId = useStore(s => s.pipelineId) @@ -69,6 +71,7 @@ const VarReferencePopup: FC = ({ zIndex={zIndex} showManageInputField={showManageRagInputFields} onManageInputField={() => setShowInputFieldPanel?.(true)} + preferSchemaType={preferSchemaType} /> } diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index 63119bb7d1..9b6ade246c 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -34,6 +34,7 @@ type ObjectChildrenProps = { onHovering?: (value: boolean) => void itemWidth?: number isSupportFileVar?: boolean + preferSchemaType?: boolean } type ItemProps = { @@ -51,6 +52,7 @@ type ItemProps = { isInCodeGeneratorInstructionEditor?: boolean zIndex?: number className?: string + preferSchemaType?: boolean } const objVarTypes = [VarType.object, VarType.file] @@ -69,6 +71,7 @@ const Item: FC = ({ isInCodeGeneratorInstructionEditor, zIndex, className, + preferSchemaType, }) => { const isStructureOutput = itemData.type === VarType.object && (itemData.children as StructuredOutput)?.schema?.properties const isFile = itemData.type === VarType.file && !isStructureOutput @@ -211,7 +214,7 @@ const Item: FC = ({
{itemData.variable.split('.').slice(-1)[0]}
)} -
{itemData.alias || itemData.type}
+
{(preferSchemaType && itemData.schemaType) ? itemData.schemaType : itemData.type}
{ (isObj || isStructureOutput) && ( @@ -224,7 +227,7 @@ const Item: FC = ({ }}> {(isStructureOutput || isObj) && ( { @@ -246,6 +249,7 @@ const ObjectChildren: FC = ({ onHovering, itemWidth, isSupportFileVar, + preferSchemaType, }) => { const currObjPath = objPath const itemRef = useRef(null) @@ -290,6 +294,7 @@ const ObjectChildren: FC = ({ onHovering={setIsChildrenHovering} isSupportFileVar={isSupportFileVar} isException={v.isException} + preferSchemaType={preferSchemaType} /> )) } @@ -312,6 +317,7 @@ type Props = { showManageInputField?: boolean onManageInputField?: () => void autoFocus?: boolean + preferSchemaType?: boolean } const VarReferenceVars: FC = ({ hideSearch, @@ -328,6 +334,7 @@ const VarReferenceVars: FC = ({ showManageInputField, onManageInputField, autoFocus = true, + preferSchemaType, }) => { const { t } = useTranslation() const [searchText, setSearchText] = useState('') @@ -417,6 +424,7 @@ const VarReferenceVars: FC = ({ isFlat={item.isFlat} isInCodeGeneratorInstructionEditor={isInCodeGeneratorInstructionEditor} zIndex={zIndex} + preferSchemaType={preferSchemaType} /> ))} {item.isFlat && !filteredVars[i + 1]?.isFlat && !!filteredVars.find(item => !item.isFlat) && ( diff --git a/web/app/components/workflow/nodes/knowledge-base/panel.tsx b/web/app/components/workflow/nodes/knowledge-base/panel.tsx index 0a5bda5d1b..be76f9009a 100644 --- a/web/app/components/workflow/nodes/knowledge-base/panel.tsx +++ b/web/app/components/workflow/nodes/knowledge-base/panel.tsx @@ -6,7 +6,6 @@ import { import { useTranslation } from 'react-i18next' import type { KnowledgeBaseNodeType } from './types' import { - ChunkStructureEnum, IndexMethodEnum, } from './types' import ChunkStructure from './components/chunk-structure' @@ -24,7 +23,6 @@ import Split from '../_base/components/split' import { useNodesReadOnly } from '@/app/components/workflow/hooks' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import type { Var } from '@/app/components/workflow/types' -import { CHUNK_TYPE_MAP } from '@/app/components/workflow/utils/tool' const Panel: FC> = ({ id, @@ -48,13 +46,9 @@ const Panel: FC> = ({ } = useConfig(id) const filterVar = useCallback((variable: Var) => { - if (data.chunk_structure === ChunkStructureEnum.general && variable.alias === CHUNK_TYPE_MAP.general_chunks) - return true - if (data.chunk_structure === ChunkStructureEnum.parent_child && variable.alias === CHUNK_TYPE_MAP.parent_child_chunks) - return true - if (data.chunk_structure === ChunkStructureEnum.question_answer && variable.alias === CHUNK_TYPE_MAP.qa_chunks) - return true - return false + // console.log(variable.schemaType) + // return variable.schemaType === 'aaa' + return true }, [data.chunk_structure]) return ( @@ -78,6 +72,7 @@ const Panel: FC> = ({ filterVar={filterVar} isFilterFileVar isSupportFileVar={false} + preferSchemaType />