diff --git a/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx b/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx index bcaa7ecb79..b032bda815 100644 --- a/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx +++ b/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx @@ -2,7 +2,6 @@ import type { FC } from 'react' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' -import { useBoolean } from 'ahooks' import type { Topic } from '../types' import TextEditor from '../../_base/components/editor/text-editor' import { Trash03 } from '@/app/components/base/icons/src/vender/line/general' @@ -13,56 +12,38 @@ type Props = { payload: Topic onChange: (payload: Topic) => void onRemove: () => void + index: number } const ClassItem: FC = ({ payload, onChange, onRemove, + index, }) => { const { t } = useTranslation() - const [isEdit, { - setTrue: setIsEditTrue, - setFalse: setIsEditFalse, - }] = useBoolean(false) - const handleTopicChange = useCallback((value: string) => { - onChange({ ...payload, topic: value }) + const handleNameChange = useCallback((value: string) => { + onChange({ ...payload, name: value }) }, [onChange, payload]) - const handleClassNameChange = useCallback((e: React.ChangeEvent) => { - onChange({ ...payload, name: e.target.value }) - }, [onChange, payload]) return (
- {isEdit - ? ( - - ) - :
- {payload.name} -
} +
+ {`${t(`${i18nPrefix}.class`)} ${index}`} +
} - value={payload.topic} - onChange={handleTopicChange} + value={payload.name} + onChange={handleNameChange} placeholder={t(`${i18nPrefix}.topicPlaceholder`)!} headerRight={(
-
{payload.topic.length}
+
{payload.name.length}
= ({ const handleAddClass = useCallback(() => { const newList = produce(list, (draft) => { - draft.push({ id: '', name: t(`${i18nPrefix}.class`) + (list.length + 1), topic: '' }) + draft.push({ id: `${Date.now()}`, name: '' }) }) onChange(newList) }, [list, onChange, t]) @@ -56,6 +56,7 @@ const ClassList: FC = ({ payload={item} onChange={handleClassChange(index)} onRemove={handleRemoveClass(index)} + index={index + 1} /> ) }) diff --git a/web/app/components/workflow/nodes/question-classifier/node.tsx b/web/app/components/workflow/nodes/question-classifier/node.tsx index 06cf487db7..7eebfde898 100644 --- a/web/app/components/workflow/nodes/question-classifier/node.tsx +++ b/web/app/components/workflow/nodes/question-classifier/node.tsx @@ -1,16 +1,20 @@ import type { FC } from 'react' import React from 'react' +import { useTranslation } from 'react-i18next' import type { NodeProps } from 'reactflow' import InfoPanel from '../_base/components/info-panel' import { NodeSourceHandle } from '../_base/components/node-handle' - import type { QuestionClassifierNodeType } from './types' import { useTextGenerationCurrentProviderAndModelAndModelList, } from '@/app/components/header/account-setting/model-provider-page/hooks' import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector' +const i18nPrefix = 'workflow.nodes.questionClassifiers' + const Node: FC> = (props) => { + const { t } = useTranslation() + const { data } = props const { provider, name: modelId } = data.model // const tempTopics = data.topics @@ -26,14 +30,14 @@ const Node: FC> = (props) => { readonly />
- {topics.map(topic => ( + {topics.map((topic, index) => (
{ setInputs(newInputs) }, [inputs, setInputs]) - const handleTopicsChange = useCallback((newTopics: any) => { + const handleClassesChange = useCallback((newClasses: any) => { const newInputs = produce(inputs, (draft) => { - draft.topics = newTopics + draft.classes = newClasses }) setInputs(newInputs) }, [inputs, setInputs]) @@ -57,7 +57,7 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => { handleModelChanged, handleCompletionParamsChange, handleQueryVarChange, - handleTopicsChange, + handleTopicsChange: handleClassesChange, handleInstructionChange, handleMemoryChange, }