Feat: Retrieval test #3221 (#7121)

### What problem does this PR solve?

Feat: Retrieval test #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-04-17 19:03:55 +08:00
committed by GitHub
parent db82c15de4
commit 86f76df586
8 changed files with 147 additions and 124 deletions

View File

@ -106,7 +106,7 @@ function RerankFormField() {
name={RerankId}
render={({ field }) => (
<FormItem>
<FormLabel>{t('rerankModel')}</FormLabel>
<FormLabel tooltip={t('rerankTip')}>{t('rerankModel')}</FormLabel>
<FormControl>
<Select onValueChange={field.onChange} {...field}>
<SelectTrigger
@ -156,7 +156,7 @@ export function RerankFormFields() {
name={'top_k'}
render={({ field }) => (
<FormItem>
<FormLabel>{t('topK')}</FormLabel>
<FormLabel tooltip={t('topKTip')}>{t('topK')}</FormLabel>
<FormControl>
<SingleFormSlider
{...field}

View File

@ -1,6 +1,7 @@
import { useTranslate } from '@/hooks/common-hooks';
import { Form, Slider } from 'antd';
import { useFormContext } from 'react-hook-form';
import { z } from 'zod';
import { SingleFormSlider } from '../ui/dual-range-slider';
import {
FormControl,
@ -55,6 +56,19 @@ interface SimilaritySliderFormFieldProps {
isTooltipShown?: boolean;
}
export const initialSimilarityThresholdValue = {
similarity_threshold: 0.2,
};
export const initialKeywordsSimilarityWeightValue = {
keywords_similarity_weight: 0.7,
};
export const similarityThresholdSchema = { similarity_threshold: z.number() };
export const keywordsSimilarityWeightSchema = {
keywords_similarity_weight: z.number(),
};
export function SimilaritySliderFormField({
vectorSimilarityWeightName = 'vector_similarity_weight',
isTooltipShown,

View File

@ -5,15 +5,23 @@ import {
FormLabel,
} from '@/components/ui/form';
import { Switch } from '@/components/ui/switch';
import { cn } from '@/lib/utils';
import { ReactNode } from 'react';
import { useFormContext } from 'react-hook-form';
interface SwitchFormItemProps {
name: string;
label: ReactNode;
vertical?: boolean;
tooltip?: ReactNode;
}
export function SwitchFormField({ label, name }: SwitchFormItemProps) {
export function SwitchFormField({
label,
name,
vertical = true,
tooltip,
}: SwitchFormItemProps) {
const form = useFormContext();
return (
@ -21,8 +29,14 @@ export function SwitchFormField({ label, name }: SwitchFormItemProps) {
control={form.control}
name={name}
render={({ field }) => (
<FormItem className="flex justify-between">
<FormLabel className="text-base">{label}</FormLabel>
<FormItem
className={cn('flex', {
'gap-2': vertical,
'flex-col': vertical,
'justify-between': !vertical,
})}
>
<FormLabel tooltip={tooltip}>{label}</FormLabel>
<FormControl>
<Switch
checked={field.value}

View File

@ -34,6 +34,7 @@ export function UseKnowledgeGraphFormField({
<SwitchFormField
name={name}
label={t('chat.useKnowledgeGraph')}
tooltip={t('chat.useKnowledgeGraphTip')}
></SwitchFormField>
);
}