diff --git a/web/src/components/llm-select/index.tsx b/web/src/components/llm-select/index.tsx index 7e1bc7a43..4d730c80c 100644 --- a/web/src/components/llm-select/index.tsx +++ b/web/src/components/llm-select/index.tsx @@ -10,12 +10,7 @@ const LLMSelect = () => { return ( - {/* Click me */} - + ); }; diff --git a/web/src/layouts/components/right-toolbar/index.tsx b/web/src/layouts/components/right-toolbar/index.tsx index 68e99201f..5970727e2 100644 --- a/web/src/layouts/components/right-toolbar/index.tsx +++ b/web/src/layouts/components/right-toolbar/index.tsx @@ -25,7 +25,9 @@ const handleGithubCLick = () => { const RightToolBar = () => { const { t } = useTranslate('common'); const changeLanguage = useChangeLanguage(); - const { language = '' } = useSelector((state) => state.settingModel.userInfo); + const { language = 'en' } = useSelector( + (state) => state.settingModel.userInfo, + ); const handleItemClick: MenuProps['onClick'] = ({ key }) => { changeLanguage(key); diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 3b96cf4da..5bc5c9177 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -505,6 +505,7 @@ export default { preview: '預覽', fileError: '文件錯誤', }, + flow: { cite: '引用', citeTip: 'citeTip' }, footer: { profile: '“保留所有權利 @ react”', }, diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 920d15127..34299e2ae 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -523,6 +523,7 @@ export default { preview: '预览', fileError: '文件错误', }, + flow: { cite: '引用', citeTip: 'citeTip' }, footer: { profile: 'All rights reserved @ React', }, diff --git a/web/src/pages/flow/canvas/node/index.tsx b/web/src/pages/flow/canvas/node/index.tsx index 18061203f..8587fa17d 100644 --- a/web/src/pages/flow/canvas/node/index.tsx +++ b/web/src/pages/flow/canvas/node/index.tsx @@ -7,6 +7,7 @@ import { Flex, MenuProps, Space, Typography } from 'antd'; import { useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { Operator, operatorMap } from '../../constant'; +import { NodeData } from '../../interface'; import OperatorIcon from '../../operator-icon'; import useGraphStore from '../../store'; import styles from './index.less'; @@ -18,7 +19,7 @@ export function RagNode({ data, isConnectable = true, selected, -}: NodeProps<{ label: string }>) { +}: NodeProps) { const { t } = useTranslation(); const deleteNodeById = useGraphStore((store) => store.deleteNodeById); const duplicateNodeById = useGraphStore((store) => store.duplicateNode); @@ -78,7 +79,7 @@ export function RagNode({ name={data.label as Operator} fontSize={12} > - {data.label} + {id} { + const form = Form.useFormInstance(); + const options = useBuildCategorizeToOptions(); + + return ( + <> + + {(fields, { add, remove }) => ( + + {fields.map((field) => ( + { + remove(field.name); + }} + /> + } + > + + + + + + + + + + + + + + ))} + + add()} block> + + Add Item + + + )} + + + + {() => ( + + {JSON.stringify(form.getFieldsValue(), null, 2)} + + )} + + > + ); +}; + +export default DynamicCategorize; diff --git a/web/src/pages/flow/categorize-form/hooks.ts b/web/src/pages/flow/categorize-form/hooks.ts new file mode 100644 index 000000000..d6ce5b3f2 --- /dev/null +++ b/web/src/pages/flow/categorize-form/hooks.ts @@ -0,0 +1,13 @@ +import { Operator } from '../constant'; +import useGraphStore from '../store'; + +// exclude some nodes downstream of the classification node +const excludedNodes = [Operator.Categorize, Operator.Answer, Operator.Begin]; + +export const useBuildCategorizeToOptions = () => { + const nodes = useGraphStore((state) => state.nodes); + + return nodes + .filter((x) => excludedNodes.every((y) => y !== x.data.label)) + .map((x) => ({ label: x.id, value: x.id })); +}; diff --git a/web/src/pages/flow/categorize-form/index.tsx b/web/src/pages/flow/categorize-form/index.tsx index 17fe73902..6cdabe3e0 100644 --- a/web/src/pages/flow/categorize-form/index.tsx +++ b/web/src/pages/flow/categorize-form/index.tsx @@ -1,10 +1,28 @@ import LLMSelect from '@/components/llm-select'; +import { useTranslate } from '@/hooks/commonHooks'; +import { Form } from 'antd'; +import { IOperatorForm } from '../interface'; +import DynamicCategorize from './dynamic-categorize'; + +const CategorizeForm = ({ form, onValuesChange }: IOperatorForm) => { + const { t } = useTranslate('flow'); -const CategorizeForm = () => { return ( - - - + + + + + + ); }; diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index acede6f72..866eb4ec8 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -80,4 +80,5 @@ export const initialFormValuesMap = { [Operator.Retrieval]: initialRetrievalValues, [Operator.Generate]: initialGenerateValues, [Operator.Answer]: {}, + [Operator.Categorize]: {}, };
{JSON.stringify(form.getFieldsValue(), null, 2)}