import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import TopKItem from '@/app/components/base/param-item/top-k-item' import ScoreThresholdItem from '@/app/components/base/param-item/score-threshold-item' import cn from '@/utils/classnames' type RetrievalSettingsProps = { topK: number scoreThreshold: number scoreThresholdEnabled: boolean isInHitTesting?: boolean isInRetrievalSetting?: boolean onChange: (data: { top_k?: number; score_threshold?: number; score_threshold_enabled?: boolean }) => void } const RetrievalSettings: FC = ({ topK, scoreThreshold, scoreThresholdEnabled, onChange, isInHitTesting = false, isInRetrievalSetting = false, }) => { const { t } = useTranslation() const handleScoreThresholdChange = (enabled: boolean) => { onChange({ score_threshold_enabled: enabled }) } return (
{!isInHitTesting && !isInRetrievalSetting &&
}
onChange({ top_k: v })} enable={true} />
onChange({ score_threshold: v })} enable={scoreThresholdEnabled} hasSwitch={true} onSwitchChange={(_key, v) => handleScoreThresholdChange(v)} />
) } export default RetrievalSettings