Fix array-only filtering in List Operator picker; remove file children fallback and align child types. (#26240)
This commit is contained in:
parent
915023b809
commit
eab6f65409
3 changed files with 23 additions and 25 deletions
|
|
@ -42,6 +42,7 @@ import type { RAGPipelineVariable } from '@/models/pipeline'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AGENT_OUTPUT_STRUCT,
|
AGENT_OUTPUT_STRUCT,
|
||||||
|
FILE_STRUCT,
|
||||||
HTTP_REQUEST_OUTPUT_STRUCT,
|
HTTP_REQUEST_OUTPUT_STRUCT,
|
||||||
KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT,
|
KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT,
|
||||||
LLM_OUTPUT_STRUCT,
|
LLM_OUTPUT_STRUCT,
|
||||||
|
|
@ -138,6 +139,10 @@ export const varTypeToStructType = (type: VarType): Type => {
|
||||||
[VarType.boolean]: Type.boolean,
|
[VarType.boolean]: Type.boolean,
|
||||||
[VarType.object]: Type.object,
|
[VarType.object]: Type.object,
|
||||||
[VarType.array]: Type.array,
|
[VarType.array]: Type.array,
|
||||||
|
[VarType.arrayString]: Type.array,
|
||||||
|
[VarType.arrayNumber]: Type.array,
|
||||||
|
[VarType.arrayObject]: Type.array,
|
||||||
|
[VarType.arrayFile]: Type.array,
|
||||||
} as any
|
} as any
|
||||||
)[type] || Type.string
|
)[type] || Type.string
|
||||||
)
|
)
|
||||||
|
|
@ -282,15 +287,6 @@ const findExceptVarInObject = (
|
||||||
children: filteredObj.children,
|
children: filteredObj.children,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isFile && Array.isArray(childrenResult)) {
|
|
||||||
if (childrenResult.length === 0) {
|
|
||||||
childrenResult = OUTPUT_FILE_SUB_VARIABLES.map(key => ({
|
|
||||||
variable: key,
|
|
||||||
type: key === 'size' ? VarType.number : VarType.string,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
childrenResult = []
|
childrenResult = []
|
||||||
|
|
@ -586,17 +582,15 @@ const formatItem = (
|
||||||
variable: outputKey,
|
variable: outputKey,
|
||||||
type:
|
type:
|
||||||
output.type === 'array'
|
output.type === 'array'
|
||||||
? (`Array[${
|
? (`Array[${output.items?.type
|
||||||
output.items?.type
|
? output.items.type.slice(0, 1).toLocaleUpperCase()
|
||||||
? output.items.type.slice(0, 1).toLocaleUpperCase()
|
+ output.items.type.slice(1)
|
||||||
+ output.items.type.slice(1)
|
: 'Unknown'
|
||||||
: 'Unknown'
|
|
||||||
}]` as VarType)
|
}]` as VarType)
|
||||||
: (`${
|
: (`${output.type
|
||||||
output.type
|
? output.type.slice(0, 1).toLocaleUpperCase()
|
||||||
? output.type.slice(0, 1).toLocaleUpperCase()
|
+ output.type.slice(1)
|
||||||
+ output.type.slice(1)
|
: 'Unknown'
|
||||||
: 'Unknown'
|
|
||||||
}` as VarType),
|
}` as VarType),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -690,9 +684,10 @@ const formatItem = (
|
||||||
const children = (() => {
|
const children = (() => {
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
return OUTPUT_FILE_SUB_VARIABLES.map((key) => {
|
return OUTPUT_FILE_SUB_VARIABLES.map((key) => {
|
||||||
|
const def = FILE_STRUCT.find(c => c.variable === key)
|
||||||
return {
|
return {
|
||||||
variable: key,
|
variable: key,
|
||||||
type: key === 'size' ? VarType.number : VarType.string,
|
type: def?.type || VarType.string,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -714,9 +709,10 @@ const formatItem = (
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
return {
|
return {
|
||||||
children: OUTPUT_FILE_SUB_VARIABLES.map((key) => {
|
children: OUTPUT_FILE_SUB_VARIABLES.map((key) => {
|
||||||
|
const def = FILE_STRUCT.find(c => c.variable === key)
|
||||||
return {
|
return {
|
||||||
variable: key,
|
variable: key,
|
||||||
type: key === 'size' ? VarType.number : VarType.string,
|
type: def?.type || VarType.string,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import { Type } from '../../../llm/types'
|
||||||
import PickerStructurePanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker'
|
import PickerStructurePanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker'
|
||||||
import { isSpecialVar, varTypeToStructType } from './utils'
|
import { isSpecialVar, varTypeToStructType } from './utils'
|
||||||
import type { Field } from '@/app/components/workflow/nodes/llm/types'
|
import type { Field } from '@/app/components/workflow/nodes/llm/types'
|
||||||
import { FILE_STRUCT } from '@/app/components/workflow/constants'
|
|
||||||
import { noop } from 'lodash-es'
|
import { noop } from 'lodash-es'
|
||||||
import { CodeAssistant, MagicEdit } from '@/app/components/base/icons/src/vender/line/general'
|
import { CodeAssistant, MagicEdit } from '@/app/components/base/icons/src/vender/line/general'
|
||||||
import ManageInputField from './manage-input-field'
|
import ManageInputField from './manage-input-field'
|
||||||
|
|
@ -106,8 +105,9 @@ const Item: FC<ItemProps> = ({
|
||||||
|
|
||||||
const objStructuredOutput: StructuredOutput | null = useMemo(() => {
|
const objStructuredOutput: StructuredOutput | null = useMemo(() => {
|
||||||
if (!isObj) return null
|
if (!isObj) return null
|
||||||
const properties: Record<string, Field> = {};
|
const properties: Record<string, Field> = {}
|
||||||
(isFile ? FILE_STRUCT : (itemData.children as Var[])).forEach((c) => {
|
const childrenVars = (itemData.children as Var[]) || []
|
||||||
|
childrenVars.forEach((c) => {
|
||||||
properties[c.variable] = {
|
properties[c.variable] = {
|
||||||
type: varTypeToStructType(c.type),
|
type: varTypeToStructType(c.type),
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +120,7 @@ const Item: FC<ItemProps> = ({
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [isFile, isObj, itemData.children])
|
}, [isObj, itemData.children])
|
||||||
|
|
||||||
const structuredOutput = (() => {
|
const structuredOutput = (() => {
|
||||||
if (isStructureOutput)
|
if (isStructureOutput)
|
||||||
|
|
@ -448,4 +448,5 @@ const VarReferenceVars: FC<Props> = ({
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default React.memo(VarReferenceVars)
|
export default React.memo(VarReferenceVars)
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
|
||||||
value={inputs.variable || []}
|
value={inputs.variable || []}
|
||||||
onChange={handleVarChanges}
|
onChange={handleVarChanges}
|
||||||
filterVar={filterVar}
|
filterVar={filterVar}
|
||||||
|
isSupportFileVar={false}
|
||||||
typePlaceHolder='Array'
|
typePlaceHolder='Array'
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue