From b4437ccd2b73ea6eac3a09728955670169a09abf Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 21 Feb 2024 14:11:51 +0800 Subject: [PATCH] chore: output lines --- .../(commonLayout)/workflow/nodes/page.tsx | 2 +- .../components/workflow/nodes/code/panel.tsx | 53 ++++--- .../nodes/direct-answer/use-config.ts | 22 +-- .../components/workflow/nodes/llm/panel.tsx | 147 +++++++++--------- .../nodes/template-transform/node.tsx | 3 +- .../nodes/template-transform/panel.tsx | 89 ++++++----- 6 files changed, 160 insertions(+), 156 deletions(-) diff --git a/web/app/(commonLayout)/workflow/nodes/page.tsx b/web/app/(commonLayout)/workflow/nodes/page.tsx index 2c6212bf2b..b411a5a839 100644 --- a/web/app/(commonLayout)/workflow/nodes/page.tsx +++ b/web/app/(commonLayout)/workflow/nodes/page.tsx @@ -48,7 +48,7 @@ const Page: FC = () => { * 2 directAnswer 3: llm 5: questionClassifier * 7 Code, 8 TemplateTransform */ - selectedNodeId='8' + selectedNodeId='3' /> ) diff --git a/web/app/components/workflow/nodes/code/panel.tsx b/web/app/components/workflow/nodes/code/panel.tsx index b37bf11a62..ef00931557 100644 --- a/web/app/components/workflow/nodes/code/panel.tsx +++ b/web/app/components/workflow/nodes/code/panel.tsx @@ -33,32 +33,37 @@ const Panel: FC = () => { handleCodeLanguageChange, } = useConfig(mockData) return ( -
- - } - > - - - - +
+ + } + > + - } - value={inputs.code} - onChange={handleCodeChange} - /> + + + + } + value={inputs.code} + onChange={handleCodeChange} + /> +
+
+ output var +
) } diff --git a/web/app/components/workflow/nodes/direct-answer/use-config.ts b/web/app/components/workflow/nodes/direct-answer/use-config.ts index 9b189e782c..55a6f724c8 100644 --- a/web/app/components/workflow/nodes/direct-answer/use-config.ts +++ b/web/app/components/workflow/nodes/direct-answer/use-config.ts @@ -1,27 +1,15 @@ import { useCallback, useState } from 'react' import produce from 'immer' -import type { Variable } from '../../types' +import useVarList from '../_base/hooks/use-var-list' import type { DirectAnswerNodeType } from './types' const useConfig = (initInputs: DirectAnswerNodeType) => { const [inputs, setInputs] = useState(initInputs) // variables - const handleVarListChange = useCallback((newList: Variable[]) => { - const newInputs = produce(inputs, (draft) => { - draft.variables = newList - }) - setInputs(newInputs) - }, [inputs, setInputs]) - - const handleAddVariable = useCallback(() => { - const newInputs = produce(inputs, (draft) => { - draft.variables.push({ - variable: '', - value_selector: [], - }) - }) - setInputs(newInputs) - }, [inputs, setInputs]) + const { handleVarListChange, handleAddVariable } = useVarList({ + inputs, + setInputs, + }) const handleAnswerChange = useCallback((value: string) => { const newInputs = produce(inputs, (draft) => { diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index d565ff8fa9..6b6b9b30b4 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -29,80 +29,85 @@ const Panel: FC = () => { // const isChatMode = modelMode === 'chat' return ( -
- - - - - - } - > - - - - +
+ + - } - > - {inputs.context.enabled - ? ( -
Context
- ) - : null} -
- - Prompt - + + + + } + > + + + + + } + > + {inputs.context.enabled + ? ( +
Context
+ ) + : null} +
+ + Prompt + + + + Vision + +
- - Vision - +
+ + <> + + + + +
- - <> - - - -
) } diff --git a/web/app/components/workflow/nodes/template-transform/node.tsx b/web/app/components/workflow/nodes/template-transform/node.tsx index b3261c4416..09b5acfb1f 100644 --- a/web/app/components/workflow/nodes/template-transform/node.tsx +++ b/web/app/components/workflow/nodes/template-transform/node.tsx @@ -2,7 +2,8 @@ import type { FC } from 'react' const Node: FC = () => { return ( -
template-transform
+ // No summary content +
) } diff --git a/web/app/components/workflow/nodes/template-transform/panel.tsx b/web/app/components/workflow/nodes/template-transform/panel.tsx index e91f2955e1..efc34b8f57 100644 --- a/web/app/components/workflow/nodes/template-transform/panel.tsx +++ b/web/app/components/workflow/nodes/template-transform/panel.tsx @@ -23,49 +23,54 @@ const Panel: FC = () => { handleCodeChange, } = useConfig(mockData) return ( -
- - } - > - - - - {t(`${i18nPrefix}.code`)}
- } - headerRight={ -
- - {t(`${i18nPrefix}.codeSupportTip`)} - - -
-
- } - value={inputs.template} - onChange={handleCodeChange} - /> - - - <> - +
+ + + } + > + - - + + + {t(`${i18nPrefix}.code`)}
+ } + headerRight={ + + } + value={inputs.template} + onChange={handleCodeChange} + /> + + +
+ + <> + + + +
) }