From e3f1e143e5672a3623f9a239c837708a9c5e9c6a Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 15 Mar 2024 18:02:54 +0800 Subject: [PATCH] feat: llm context type limit --- web/app/components/workflow/nodes/llm/panel.tsx | 3 +++ web/app/components/workflow/nodes/llm/use-config.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index cff5b89c7e..a462c55fc0 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -43,6 +43,7 @@ const Panel: FC> = ({ handleVarListChange, handleAddVariable, handleContextVarChange, + filterVar, handlePromptChange, handleMemoryChange, handleVisionResolutionChange, @@ -168,6 +169,8 @@ const Panel: FC> = ({ isShowNodeName value={inputs.context?.variable_selector || []} onChange={handleContextVarChange} + filterVar={filterVar} + width={370} /> diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts index 50306233d6..80937d50df 100644 --- a/web/app/components/workflow/nodes/llm/use-config.ts +++ b/web/app/components/workflow/nodes/llm/use-config.ts @@ -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,