chore: some special to some fns

pull/21398/head
Joel 12 months ago
parent e290ddc3e5
commit cab491795a

@ -56,6 +56,10 @@ export const isRagVariableVar = (valueSelector: ValueSelector) => {
return valueSelector[0] === 'rag' return valueSelector[0] === 'rag'
} }
export const isSpecialVar = (prefix: string): boolean => {
return ['sys', 'env', 'conversation', 'rag'].includes(prefix)
}
const inputVarTypeToVarType = (type: InputVarType): VarType => { const inputVarTypeToVarType = (type: InputVarType): VarType => {
return ({ return ({
[InputVarType.number]: VarType.number, [InputVarType.number]: VarType.number,
@ -527,7 +531,7 @@ const formatItem = (
const isCurrentMatched = filterVar(v, (() => { const isCurrentMatched = filterVar(v, (() => {
const variableArr = v.variable.split('.') const variableArr = v.variable.split('.')
const [first] = variableArr const [first] = variableArr
if (first === 'sys' || first === 'env' || first === 'conversation' || first === 'rag') if (isSpecialVar(first))
return variableArr return variableArr
return [...selector, ...variableArr] return [...selector, ...variableArr]

@ -18,7 +18,7 @@ import { checkKeys } from '@/utils/var'
import type { StructuredOutput } from '../../../llm/types' import type { StructuredOutput } from '../../../llm/types'
import { Type } from '../../../llm/types' 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 { 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 { FILE_STRUCT } from '@/app/components/workflow/constants'
import { Loop } from '@/app/components/base/icons/src/vender/workflow' import { Loop } from '@/app/components/base/icons/src/vender/workflow'
@ -286,7 +286,7 @@ const VarReferenceVars: FC<Props> = ({
} }
const filteredVars = vars.filter((v) => { const filteredVars = vars.filter((v) => {
const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.') || v.variable.startsWith('env.') || v.variable.startsWith('conversation.') || v.variable.startsWith('rag.')) const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || isSpecialVar(v.variable.split('.')[0]))
return children.length > 0 return children.length > 0
}).filter((node) => { }).filter((node) => {
if (!searchText) if (!searchText)
@ -297,7 +297,7 @@ const VarReferenceVars: FC<Props> = ({
}) })
return children.length > 0 return children.length > 0
}).map((node) => { }).map((node) => {
let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.') || v.variable.startsWith('env.') || v.variable.startsWith('conversation.') || v.variable.startsWith('rag.')) let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || isSpecialVar(v.variable.split('.')[0]))
if (searchText) { if (searchText) {
const searchTextLower = searchText.toLowerCase() const searchTextLower = searchText.toLowerCase()
if (!node.title.toLowerCase().includes(searchTextLower)) if (!node.title.toLowerCase().includes(searchTextLower))

Loading…
Cancel
Save