feat: ignore invalid vars keys

This commit is contained in:
Joel 2024-03-29 13:56:13 +08:00
parent 91b84d8f1e
commit 8d2ac8ff8f
2 changed files with 9 additions and 8 deletions

View File

@ -443,10 +443,6 @@ const varsToValueSelectorList = (vars: Var | Var[], parentValueSelector: ValueSe
varToValueSelectorList(vars as Var, parentValueSelector, res)
}
// const test: ValueSelector[] = []
// varsToValueSelectorList(LLM_OUTPUT_STRUCT, ['ttt'], test)
// console.log(test)
export const getNodeOutputVars = (node: Node, isChatMode: boolean): ValueSelector[] => {
const { data, id } = node
const { type } = data

View File

@ -16,6 +16,7 @@ import {
SearchLg,
} from '@/app/components/base/icons/src/vender/line/general'
import { XCircle } from '@/app/components/base/icons/src/vender/solid/general'
import { checkKeys } from '@/utils/var'
type ObjectChildrenProps = {
nodeId: string
@ -200,17 +201,21 @@ const VarReferenceVars: FC<Props> = ({
const { t } = useTranslation()
const [searchText, setSearchText] = useState('')
const filteredVars = vars.filter((v) => {
const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
return children.length > 0
}).filter((v) => {
if (!searchText)
return v
const children = v.vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
return children.length > 0
}).map((v) => {
if (!searchText)
return v
const children = v.vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
let vars = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.'))
if (searchText)
vars = vars.filter(v => v.variable.toLowerCase().includes(searchText.toLowerCase()))
return {
...v,
vars: children,
vars,
}
})
// max-h-[300px] overflow-y-auto todo: use portal to handle long list