mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-11 09:51:44 +08:00
Fix: restrict keywords_similarity_weight [0,1] (#18044)
This commit is contained in:
@@ -32,7 +32,7 @@ export const initialKeywordsSimilarityWeightValue = {
|
||||
export const similarityThresholdSchema = { similarity_threshold: z.number() };
|
||||
|
||||
export const keywordsSimilarityWeightSchema = {
|
||||
keywords_similarity_weight: z.number(),
|
||||
keywords_similarity_weight: z.number().min(0).max(1),
|
||||
};
|
||||
|
||||
export const vectorSimilarityWeightSchema = {
|
||||
@@ -53,7 +53,8 @@ export function SimilaritySliderFormField({
|
||||
const { t } = useTranslate('knowledgeDetails');
|
||||
const form = useFormContext();
|
||||
const isVector = similarityWeightType === 'vector';
|
||||
const normalizeWeight = (weight: number) => Number(weight.toFixed(2));
|
||||
const normalizeWeight = (weight: number) =>
|
||||
Number(Math.min(1, Math.max(0, weight)).toFixed(2));
|
||||
const getVectorWeight = (weight: number) =>
|
||||
normalizeWeight(isVector ? weight : 1 - weight);
|
||||
const getFullTextWeight = (weight: number) =>
|
||||
@@ -137,7 +138,9 @@ export function SimilaritySliderFormField({
|
||||
step={0.01}
|
||||
{...field}
|
||||
value={getVectorWeight(field.value)}
|
||||
onChange={(value) => field.onChange(getStoredWeight(value))}
|
||||
onChange={(value) =>
|
||||
field.onChange(getStoredWeight(Number(value)))
|
||||
}
|
||||
></NumberInput>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,7 @@ import { useValues } from './use-values';
|
||||
|
||||
export const RetrievalPartialSchema = {
|
||||
similarity_threshold: z.coerce.number(),
|
||||
keywords_similarity_weight: z.coerce.number(),
|
||||
keywords_similarity_weight: z.coerce.number().min(0).max(1),
|
||||
top_n: z.coerce.number(),
|
||||
top_k: z.coerce.number(),
|
||||
dataset_ids: z.array(z.string()),
|
||||
|
||||
Reference in New Issue
Block a user