mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Add DualRangeSlider #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import { useTranslate } from '@/hooks/common-hooks';
|
|
import { Form, Slider } from 'antd';
|
|
import { useFormContext } from 'react-hook-form';
|
|
import { SingleFormSlider } from './ui/dual-range-slider';
|
|
import {
|
|
FormControl,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from './ui/form';
|
|
|
|
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 function TopNFormField({ max = 30 }: SimilaritySliderFormFieldProps) {
|
|
const form = useFormContext();
|
|
const { t } = useTranslate('chat');
|
|
|
|
return (
|
|
<FormField
|
|
control={form.control}
|
|
name={'top_n'}
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>{t('topN')}</FormLabel>
|
|
<FormControl>
|
|
<SingleFormSlider {...field} max={max}></SingleFormSlider>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
);
|
|
}
|