mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 23:16:58 +08:00
### What problem does this PR solve? Fix: Refactor the similarity slider component and modify the style of the dataset-test page ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { FormLayout } from '@/constants/form';
|
|
import { useTranslate } from '@/hooks/common-hooks';
|
|
import { Form, Slider } from 'antd';
|
|
import { z } from 'zod';
|
|
import { SliderInputFormField } from './slider-input-form-field';
|
|
|
|
type FieldType = {
|
|
top_n?: number;
|
|
};
|
|
|
|
interface IProps {
|
|
initialValue?: number;
|
|
max?: number;
|
|
}
|
|
|
|
const TopNItem = ({ initialValue = 8, max = 30 }: IProps) => {
|
|
const { t } = useTranslate('chat');
|
|
|
|
return (
|
|
<Form.Item<FieldType>
|
|
label={t('topN')}
|
|
name={'top_n'}
|
|
initialValue={initialValue}
|
|
tooltip={t('topNTip')}
|
|
>
|
|
<Slider max={max} />
|
|
</Form.Item>
|
|
);
|
|
};
|
|
|
|
export default TopNItem;
|
|
|
|
interface SimilaritySliderFormFieldProps {
|
|
max?: number;
|
|
}
|
|
|
|
export const topnSchema = {
|
|
top_n: z.number().optional(),
|
|
};
|
|
|
|
export function TopNFormField({ max = 30 }: SimilaritySliderFormFieldProps) {
|
|
const { t } = useTranslate('chat');
|
|
|
|
return (
|
|
<SliderInputFormField
|
|
name={'top_n'}
|
|
label={t('topN')}
|
|
max={max}
|
|
tooltip={t('topNTip')}
|
|
layout={FormLayout.Vertical}
|
|
></SliderInputFormField>
|
|
);
|
|
}
|