### What problem does this PR solve? feat: build categorize list from object #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -1,44 +1,13 @@
|
||||
import LlmSettingItems from '@/components/llm-setting-items';
|
||||
import { variableEnabledFieldMap } from '@/constants/chat';
|
||||
import {
|
||||
ModelVariableType,
|
||||
settledModelVariableMap,
|
||||
} from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { Variable } from '@/interfaces/database/chat';
|
||||
import { Form, Input, Switch } from 'antd';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useSetLlmSetting } from '../hooks';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
const GenerateForm = ({ onValuesChange, form }: IOperatorForm) => {
|
||||
const { t } = useTranslate('flow');
|
||||
const initialLlmSetting = undefined;
|
||||
|
||||
const handleParametersChange = useCallback(
|
||||
(value: ModelVariableType) => {
|
||||
const variable = settledModelVariableMap[value];
|
||||
form?.setFieldsValue(variable);
|
||||
},
|
||||
[form],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
||||
Record<string, boolean>
|
||||
>((pre, field) => {
|
||||
pre[field] =
|
||||
initialLlmSetting === undefined
|
||||
? true
|
||||
: !!initialLlmSetting[
|
||||
variableEnabledFieldMap[
|
||||
field as keyof typeof variableEnabledFieldMap
|
||||
] as keyof Variable
|
||||
];
|
||||
return pre;
|
||||
}, {});
|
||||
const otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
||||
form?.setFieldsValue({ ...switchBoxValues, ...otherValues });
|
||||
}, [form, initialLlmSetting]);
|
||||
useSetLlmSetting(form);
|
||||
|
||||
return (
|
||||
<Form
|
||||
@@ -49,9 +18,7 @@ const GenerateForm = ({ onValuesChange, form }: IOperatorForm) => {
|
||||
form={form}
|
||||
onValuesChange={onValuesChange}
|
||||
>
|
||||
<LlmSettingItems
|
||||
handleParametersChange={handleParametersChange}
|
||||
></LlmSettingItems>
|
||||
<LlmSettingItems></LlmSettingItems>
|
||||
<Form.Item
|
||||
name={['prompt']}
|
||||
label={t('prompt', { keyPrefix: 'knowledgeConfiguration' })}
|
||||
|
||||
Reference in New Issue
Block a user