chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
+80
@@ -0,0 +1,80 @@
|
||||
import type { FC } from 'react'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import ScoreThresholdItem from '@/app/components/base/param-item/score-threshold-item'
|
||||
import TopKItem from '@/app/components/base/param-item/top-k-item'
|
||||
|
||||
type RetrievalSettingsProps = {
|
||||
topK: number
|
||||
scoreThreshold: number
|
||||
scoreThresholdEnabled: boolean
|
||||
isInHitTesting?: boolean
|
||||
isInRetrievalSetting?: boolean
|
||||
readonly?: boolean
|
||||
onChange: (data: {
|
||||
top_k?: number
|
||||
score_threshold?: number
|
||||
score_threshold_enabled?: boolean
|
||||
}) => void
|
||||
}
|
||||
|
||||
const RetrievalSettings: FC<RetrievalSettingsProps> = ({
|
||||
topK,
|
||||
scoreThreshold,
|
||||
scoreThresholdEnabled,
|
||||
onChange,
|
||||
isInHitTesting = false,
|
||||
isInRetrievalSetting = false,
|
||||
readonly = false,
|
||||
}) => {
|
||||
const { t } = useTranslation(['dataset'])
|
||||
|
||||
const handleScoreThresholdChange = (enabled: boolean) => {
|
||||
onChange({ score_threshold_enabled: enabled })
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn('flex flex-col gap-2 self-stretch', isInRetrievalSetting && 'w-full max-w-120')}
|
||||
>
|
||||
{!isInHitTesting && !isInRetrievalSetting && (
|
||||
<div className="flex h-7 flex-col gap-2 self-stretch pt-1">
|
||||
<label className="system-sm-semibold text-text-secondary">
|
||||
{t(($) => $.retrievalSettings, { ns: 'dataset' })}
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className={cn('flex gap-4 self-stretch', {
|
||||
'flex-col': isInHitTesting,
|
||||
'flex-row': isInRetrievalSetting,
|
||||
'flex-col sm:flex-row': !isInHitTesting && !isInRetrievalSetting,
|
||||
})}
|
||||
>
|
||||
<div className="flex grow flex-col gap-1">
|
||||
<TopKItem
|
||||
className="grow"
|
||||
value={topK}
|
||||
onChange={(_key, v) => onChange({ top_k: v })}
|
||||
enable={true}
|
||||
disabled={readonly}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex grow flex-col gap-1">
|
||||
<ScoreThresholdItem
|
||||
className="grow"
|
||||
value={scoreThreshold}
|
||||
onChange={(_key, v) => onChange({ score_threshold: v })}
|
||||
enable={scoreThresholdEnabled}
|
||||
hasSwitch={true}
|
||||
onSwitchChange={(_key, v) => handleScoreThresholdChange(v)}
|
||||
disabled={readonly}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RetrievalSettings
|
||||
Reference in new issue
Block a user