Feat: Add hatPromptEngine component #3221 (#4881)

### What problem does this PR solve?

Feat: Add hatPromptEngine component #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-02-11 19:04:10 +08:00
committed by GitHub
parent 521d25d4e6
commit d197f33646
9 changed files with 398 additions and 142 deletions

View File

@ -1,5 +1,14 @@
import { useTranslate } from '@/hooks/common-hooks';
import { Form, Slider } from 'antd';
import { useFormContext } from 'react-hook-form';
import {
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from './ui/form';
import { FormSlider } from './ui/slider';
type FieldType = {
top_n?: number;
@ -26,3 +35,28 @@ const TopNItem = ({ initialValue = 8, max = 30 }: IProps) => {
};
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>
<FormSlider {...field} max={max}></FormSlider>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
);
}