mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com> Co-authored-by: Jin Hai <haijin.chn@gmail.com>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import classNames from 'classnames';
|
|
import { useEffect } from 'react';
|
|
import { ISegmentedContentProps } from '../interface';
|
|
|
|
import LlmSettingItems from '@/components/llm-setting-items';
|
|
import { variableEnabledFieldMap } from '@/constants/chat';
|
|
import { Variable } from '@/interfaces/database/chat';
|
|
import styles from './index.less';
|
|
|
|
const ModelSetting = ({
|
|
show,
|
|
form,
|
|
initialLlmSetting,
|
|
visible,
|
|
}: ISegmentedContentProps & {
|
|
initialLlmSetting?: Variable;
|
|
visible?: boolean;
|
|
}) => {
|
|
useEffect(() => {
|
|
if (visible) {
|
|
const values = 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;
|
|
}, {});
|
|
form.setFieldsValue(values);
|
|
}
|
|
}, [form, initialLlmSetting, visible]);
|
|
|
|
return (
|
|
<section
|
|
className={classNames({
|
|
[styles.segmentedHidden]: !show,
|
|
})}
|
|
>
|
|
{visible && <LlmSettingItems prefix="llm_setting"></LlmSettingItems>}
|
|
</section>
|
|
);
|
|
};
|
|
|
|
export default ModelSetting;
|