feat: llm context type limit

This commit is contained in:
Joel 2024-03-15 18:02:54 +08:00
parent 9f1cbb2ee7
commit e3f1e143e5
2 changed files with 10 additions and 1 deletions

View File

@ -43,6 +43,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
handleVarListChange,
handleAddVariable,
handleContextVarChange,
filterVar,
handlePromptChange,
handleMemoryChange,
handleVisionResolutionChange,
@ -168,6 +169,8 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
isShowNodeName
value={inputs.context?.variable_selector || []}
onChange={handleContextVarChange}
filterVar={filterVar}
width={370}
/>
</Field>

View File

@ -1,7 +1,8 @@
import { useCallback } from 'react'
import produce from 'immer'
import useVarList from '../_base/hooks/use-var-list'
import { type Memory, PromptRole, type ValueSelector } from '../../types'
import { PromptRole, VarType } from '../../types'
import type { Memory, ValueSelector, Var } from '../../types'
import type { LLMNodeType } from './types'
import { Resolution } from '@/types/app'
import { useTextGenerationCurrentProviderAndModelAndModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'
@ -89,6 +90,10 @@ const useConfig = (id: string, payload: LLMNodeType) => {
setInputs(newInputs)
}, [inputs, setInputs])
const filterVar = useCallback((varPayload: Var) => {
return [VarType.arrayObject, VarType.string].includes(varPayload.type)
}, [])
// single run
const {
isShowSingleRun,
@ -156,6 +161,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
handleVarListChange,
handleAddVariable,
handleContextVarChange,
filterVar,
handlePromptChange,
handleMemoryChange,
handleVisionResolutionChange,