46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
![]() |
import type { FC } from 'react'
|
||
|
import React, { useState } 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'
|
||
|
|
||
|
type RetrievalSettingsProps = {
|
||
|
topK: number
|
||
|
scoreThreshold: number
|
||
|
onChange: (data: { top_k?: number; score_threshold?: number }) => void
|
||
|
}
|
||
|
|
||
|
const RetrievalSettings: FC<RetrievalSettingsProps> = ({ topK, scoreThreshold, onChange }) => {
|
||
|
const [scoreThresholdEnabled, setScoreThresholdEnabled] = useState(false)
|
||
|
const { t } = useTranslation()
|
||
|
return (
|
||
|
<div className='flex flex-col gap-2 self-stretch'>
|
||
|
<div className='flex h-7 pt-1 flex-col gap-2 self-stretch'>
|
||
|
<label className='text-text-secondary system-sm-semibold'>{t('dataset.retrievalSettings')}</label>
|
||
|
</div>
|
||
|
<div className='flex gap-4 self-stretch'>
|
||
|
<div className='flex flex-col gap-1 flex-grow'>
|
||
|
<TopKItem
|
||
|
className='grow'
|
||
|
value={topK}
|
||
|
onChange={(_key, v) => onChange({ top_k: v })}
|
||
|
enable={true}
|
||
|
/>
|
||
|
</div>
|
||
|
<div className='flex flex-col gap-1 flex-grow'>
|
||
|
<ScoreThresholdItem
|
||
|
className='grow'
|
||
|
value={scoreThreshold}
|
||
|
onChange={(_key, v) => onChange({ score_threshold: v })}
|
||
|
enable={scoreThresholdEnabled}
|
||
|
hasSwitch={true}
|
||
|
onSwitchChange={(_key, v) => setScoreThresholdEnabled(v)}
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
export default RetrievalSettings
|