chore: schema type change

This commit is contained in:
Joel 2025-08-27 17:39:43 +08:00
parent ee144452e2
commit 19d3ba42e5
6 changed files with 22 additions and 13 deletions

View File

@ -221,7 +221,7 @@ const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: Val
variable: obj.variable, variable: obj.variable,
type: isFile ? VarType.file : VarType.object, type: isFile ? VarType.file : VarType.object,
children: childrenResult, children: childrenResult,
alias: obj.alias, schemaType: obj.schemaType,
} }
return res return res

View File

@ -79,6 +79,7 @@ type Props = {
zIndex?: number zIndex?: number
currentTool?: Tool currentTool?: Tool
currentProvider?: ToolWithProvider currentProvider?: ToolWithProvider
preferSchemaType?: boolean
} }
const DEFAULT_VALUE_SELECTOR: Props['value'] = [] const DEFAULT_VALUE_SELECTOR: Props['value'] = []
@ -111,6 +112,7 @@ const VarReferencePicker: FC<Props> = ({
zIndex, zIndex,
currentTool, currentTool,
currentProvider, currentProvider,
preferSchemaType,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const store = useStoreApi() const store = useStoreApi()
@ -562,6 +564,7 @@ const VarReferencePicker: FC<Props> = ({
itemWidth={isAddBtnTrigger ? 260 : (minWidth || triggerWidth)} itemWidth={isAddBtnTrigger ? 260 : (minWidth || triggerWidth)}
isSupportFileVar={isSupportFileVar} isSupportFileVar={isSupportFileVar}
zIndex={zIndex} zIndex={zIndex}
preferSchemaType={preferSchemaType}
/> />
)} )}
</PortalToFollowElemContent> </PortalToFollowElemContent>

View File

@ -15,6 +15,7 @@ type Props = {
itemWidth?: number itemWidth?: number
isSupportFileVar?: boolean isSupportFileVar?: boolean
zIndex?: number zIndex?: number
preferSchemaType?: boolean
} }
const VarReferencePopup: FC<Props> = ({ const VarReferencePopup: FC<Props> = ({
vars, vars,
@ -23,6 +24,7 @@ const VarReferencePopup: FC<Props> = ({
itemWidth, itemWidth,
isSupportFileVar = true, isSupportFileVar = true,
zIndex, zIndex,
preferSchemaType,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const pipelineId = useStore(s => s.pipelineId) const pipelineId = useStore(s => s.pipelineId)
@ -69,6 +71,7 @@ const VarReferencePopup: FC<Props> = ({
zIndex={zIndex} zIndex={zIndex}
showManageInputField={showManageRagInputFields} showManageInputField={showManageRagInputFields}
onManageInputField={() => setShowInputFieldPanel?.(true)} onManageInputField={() => setShowInputFieldPanel?.(true)}
preferSchemaType={preferSchemaType}
/> />
} }
</div > </div >

View File

@ -34,6 +34,7 @@ type ObjectChildrenProps = {
onHovering?: (value: boolean) => void onHovering?: (value: boolean) => void
itemWidth?: number itemWidth?: number
isSupportFileVar?: boolean isSupportFileVar?: boolean
preferSchemaType?: boolean
} }
type ItemProps = { type ItemProps = {
@ -51,6 +52,7 @@ type ItemProps = {
isInCodeGeneratorInstructionEditor?: boolean isInCodeGeneratorInstructionEditor?: boolean
zIndex?: number zIndex?: number
className?: string className?: string
preferSchemaType?: boolean
} }
const objVarTypes = [VarType.object, VarType.file] const objVarTypes = [VarType.object, VarType.file]
@ -69,6 +71,7 @@ const Item: FC<ItemProps> = ({
isInCodeGeneratorInstructionEditor, isInCodeGeneratorInstructionEditor,
zIndex, zIndex,
className, className,
preferSchemaType,
}) => { }) => {
const isStructureOutput = itemData.type === VarType.object && (itemData.children as StructuredOutput)?.schema?.properties const isStructureOutput = itemData.type === VarType.object && (itemData.children as StructuredOutput)?.schema?.properties
const isFile = itemData.type === VarType.file && !isStructureOutput const isFile = itemData.type === VarType.file && !isStructureOutput
@ -211,7 +214,7 @@ const Item: FC<ItemProps> = ({
<div title={itemData.des} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable.split('.').slice(-1)[0]}</div> <div title={itemData.des} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable.split('.').slice(-1)[0]}</div>
)} )}
</div> </div>
<div className='ml-1 shrink-0 text-xs font-normal capitalize text-text-tertiary'>{itemData.alias || itemData.type}</div> <div className='ml-1 shrink-0 text-xs font-normal capitalize text-text-tertiary'>{(preferSchemaType && itemData.schemaType) ? itemData.schemaType : itemData.type}</div>
{ {
(isObj || isStructureOutput) && ( (isObj || isStructureOutput) && (
<ChevronRight className={cn('ml-0.5 h-3 w-3 text-text-quaternary', isHovering && 'text-text-tertiary')} /> <ChevronRight className={cn('ml-0.5 h-3 w-3 text-text-quaternary', isHovering && 'text-text-tertiary')} />
@ -224,7 +227,7 @@ const Item: FC<ItemProps> = ({
}}> }}>
{(isStructureOutput || isObj) && ( {(isStructureOutput || isObj) && (
<PickerStructurePanel <PickerStructurePanel
root={{ nodeId, nodeName: title, attrName: itemData.variable, attrAlias: itemData.alias }} root={{ nodeId, nodeName: title, attrName: itemData.variable, attrAlias: itemData.schemaType }}
payload={structuredOutput!} payload={structuredOutput!}
onHovering={setIsChildrenHovering} onHovering={setIsChildrenHovering}
onSelect={(valueSelector) => { onSelect={(valueSelector) => {
@ -246,6 +249,7 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
onHovering, onHovering,
itemWidth, itemWidth,
isSupportFileVar, isSupportFileVar,
preferSchemaType,
}) => { }) => {
const currObjPath = objPath const currObjPath = objPath
const itemRef = useRef<HTMLDivElement>(null) const itemRef = useRef<HTMLDivElement>(null)
@ -290,6 +294,7 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
onHovering={setIsChildrenHovering} onHovering={setIsChildrenHovering}
isSupportFileVar={isSupportFileVar} isSupportFileVar={isSupportFileVar}
isException={v.isException} isException={v.isException}
preferSchemaType={preferSchemaType}
/> />
)) ))
} }
@ -312,6 +317,7 @@ type Props = {
showManageInputField?: boolean showManageInputField?: boolean
onManageInputField?: () => void onManageInputField?: () => void
autoFocus?: boolean autoFocus?: boolean
preferSchemaType?: boolean
} }
const VarReferenceVars: FC<Props> = ({ const VarReferenceVars: FC<Props> = ({
hideSearch, hideSearch,
@ -328,6 +334,7 @@ const VarReferenceVars: FC<Props> = ({
showManageInputField, showManageInputField,
onManageInputField, onManageInputField,
autoFocus = true, autoFocus = true,
preferSchemaType,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [searchText, setSearchText] = useState('') const [searchText, setSearchText] = useState('')
@ -417,6 +424,7 @@ const VarReferenceVars: FC<Props> = ({
isFlat={item.isFlat} isFlat={item.isFlat}
isInCodeGeneratorInstructionEditor={isInCodeGeneratorInstructionEditor} isInCodeGeneratorInstructionEditor={isInCodeGeneratorInstructionEditor}
zIndex={zIndex} zIndex={zIndex}
preferSchemaType={preferSchemaType}
/> />
))} ))}
{item.isFlat && !filteredVars[i + 1]?.isFlat && !!filteredVars.find(item => !item.isFlat) && ( {item.isFlat && !filteredVars[i + 1]?.isFlat && !!filteredVars.find(item => !item.isFlat) && (

View File

@ -6,7 +6,6 @@ import {
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import type { KnowledgeBaseNodeType } from './types' import type { KnowledgeBaseNodeType } from './types'
import { import {
ChunkStructureEnum,
IndexMethodEnum, IndexMethodEnum,
} from './types' } from './types'
import ChunkStructure from './components/chunk-structure' import ChunkStructure from './components/chunk-structure'
@ -24,7 +23,6 @@ import Split from '../_base/components/split'
import { useNodesReadOnly } from '@/app/components/workflow/hooks' import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
import type { Var } from '@/app/components/workflow/types' import type { Var } from '@/app/components/workflow/types'
import { CHUNK_TYPE_MAP } from '@/app/components/workflow/utils/tool'
const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({ const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
id, id,
@ -48,13 +46,9 @@ const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
} = useConfig(id) } = useConfig(id)
const filterVar = useCallback((variable: Var) => { const filterVar = useCallback((variable: Var) => {
if (data.chunk_structure === ChunkStructureEnum.general && variable.alias === CHUNK_TYPE_MAP.general_chunks) // console.log(variable.schemaType)
return true // return variable.schemaType === 'aaa'
if (data.chunk_structure === ChunkStructureEnum.parent_child && variable.alias === CHUNK_TYPE_MAP.parent_child_chunks) return true
return true
if (data.chunk_structure === ChunkStructureEnum.question_answer && variable.alias === CHUNK_TYPE_MAP.qa_chunks)
return true
return false
}, [data.chunk_structure]) }, [data.chunk_structure])
return ( return (
@ -78,6 +72,7 @@ const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
filterVar={filterVar} filterVar={filterVar}
isFilterFileVar isFilterFileVar
isSupportFileVar={false} isSupportFileVar={false}
preferSchemaType
/> />
</BoxGroupField> </BoxGroupField>
<Group <Group

View File

@ -305,7 +305,7 @@ export type Var = {
isLoopVariable?: boolean isLoopVariable?: boolean
nodeId?: string nodeId?: string
isRagVariable?: boolean isRagVariable?: boolean
alias?: string schemaType?: string
} }
export type NodeOutPutVar = { export type NodeOutPutVar = {