diff --git a/web/app/(commonLayout)/workflow/nodes/page.tsx b/web/app/(commonLayout)/workflow/nodes/page.tsx index 3692cc9066..7dc849e616 100644 --- a/web/app/(commonLayout)/workflow/nodes/page.tsx +++ b/web/app/(commonLayout)/workflow/nodes/page.tsx @@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow' import { BlockEnum } from '@/app/components/workflow/types' const nodes = [ - BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.QuestionClassifier/* 5 */, + BlockEnum.LLM/* 3 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.QuestionClassifier/* 5 */, BlockEnum.IfElse/* 6 */, BlockEnum.Code/* 7 */, BlockEnum.TemplateTransform/* 8 */, BlockEnum.HttpRequest/* 9 */, BlockEnum.Tool/* 10 */, BlockEnum.VariableAssigner/* 11 */, BlockEnum.End/* 12 */, ].map((item, i) => ({ diff --git a/web/app/components/workflow/nodes/llm/mock.ts b/web/app/components/workflow/nodes/llm/mock.ts index be87ddc92d..db64e0d375 100644 --- a/web/app/components/workflow/nodes/llm/mock.ts +++ b/web/app/components/workflow/nodes/llm/mock.ts @@ -34,7 +34,7 @@ export const mockData: LLMNodeType = { }, context: { enabled: false, - size: 0, + variable_selector: ['aaa', 'name'], }, vision: { enabled: false, diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index fa70e61bd2..64bd91cf88 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -1,6 +1,7 @@ import type { FC } from 'react' import { useTranslation } from 'react-i18next' import MemoryConfig from '../_base/components/memory-config' +import VarReferencePicker from '../_base/components/variable/var-reference-picker' import useConfig from './use-config' import { mockData } from './mock' import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list' @@ -8,7 +9,6 @@ import Field from '@/app/components/workflow/nodes/_base/components/field' import AddButton from '@/app/components/base/button/add-button' import Split from '@/app/components/workflow/nodes/_base/components/split' import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' -import Switch from '@/app/components/base/switch' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' const i18nPrefix = 'workflow.nodes.llm' @@ -23,7 +23,7 @@ const Panel: FC = () => { handleCompletionParamsChange, handleVarListChange, handleAddVariable, - toggleContextEnabled, + handleContextVarChange, handleMemoryChange, } = useConfig(mockData) const model = inputs.model @@ -63,21 +63,18 @@ const Panel: FC = () => { /> + {/* knowledge */} - } + tooltip={t(`${i18nPrefix}.contextTooltip`)!} > - {inputs.context.enabled - ? ( -
Context
- ) - : null} + +
{/* Prompt */} diff --git a/web/app/components/workflow/nodes/llm/types.ts b/web/app/components/workflow/nodes/llm/types.ts index 7fa593fea6..381da95d5d 100644 --- a/web/app/components/workflow/nodes/llm/types.ts +++ b/web/app/components/workflow/nodes/llm/types.ts @@ -8,7 +8,7 @@ export type LLMNodeType = CommonNodeType & { memory: Memory context: { enabled: boolean - size: number + variable_selector: ValueSelector } vision: { enabled: boolean diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts index 99a3e57c58..e2b6aaa1b0 100644 --- a/web/app/components/workflow/nodes/llm/use-config.ts +++ b/web/app/components/workflow/nodes/llm/use-config.ts @@ -1,7 +1,7 @@ import { useCallback, useState } from 'react' import produce from 'immer' import useVarList from '../_base/hooks/use-var-list' -import type { Memory } from '../../types' +import type { Memory, ValueSelector } from '../../types' import type { LLMNodeType } from './types' const useConfig = (initInputs: LLMNodeType) => { @@ -31,9 +31,9 @@ const useConfig = (initInputs: LLMNodeType) => { }) // context - const toggleContextEnabled = useCallback(() => { + const handleContextVarChange = useCallback((newVar: ValueSelector) => { const newInputs = produce(inputs, (draft) => { - draft.context.enabled = !draft.context.enabled + draft.context.variable_selector = newVar }) setInputs(newInputs) }, [inputs, setInputs]) @@ -51,7 +51,7 @@ const useConfig = (initInputs: LLMNodeType) => { handleCompletionParamsChange, handleVarListChange, handleAddVariable, - toggleContextEnabled, + handleContextVarChange, handleMemoryChange, } } diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 0b9650d0d9..02f7ad828f 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -47,6 +47,7 @@ const translation = { model: 'model', variables: 'variables', context: 'context', + contextTooltip: 'You can import Knowledge as context', prompt: 'prompt', vision: 'vision', outputVars: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 5c2ff57c06..b618c472ca 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -14,6 +14,7 @@ const translation = { }, start: { required: '必填', + inputField: '输入字段', builtInVar: '内置变量', outputVars: { query: '用户输入', @@ -46,6 +47,7 @@ const translation = { model: '模型', variables: '变量', context: '上下文', + contextTooltip: '您可以导入知识库作为上下文', prompt: '提示词', vision: '视觉', outputVars: {