mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: option card component
chore: upd
This commit is contained in:
@ -3,10 +3,10 @@ import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import RetrievalParamConfig from '../retrieval-param-config'
|
||||
import { OptionCard } from '../../create/step-two/option-card'
|
||||
import { RETRIEVE_METHOD } from '@/types/app'
|
||||
import RadioCard from '@/app/components/base/radio-card'
|
||||
import { HighPriority } from '@/app/components/base/icons/src/vender/solid/arrows'
|
||||
import type { RetrievalConfig } from '@/types/app'
|
||||
import { HighPriority } from '@/app/components/base/icons/src/vender/solid/arrows'
|
||||
|
||||
type Props = {
|
||||
value: RetrievalConfig
|
||||
@ -21,19 +21,15 @@ const EconomicalRetrievalMethodConfig: FC<Props> = ({
|
||||
|
||||
return (
|
||||
<div className='space-y-2'>
|
||||
<RadioCard
|
||||
icon={<HighPriority className='w-4 h-4 text-[#7839EE]' />}
|
||||
<OptionCard icon={<HighPriority className='w-4 h-4 text-[#7839EE]' />}
|
||||
title={t('dataset.retrieval.invertedIndex.title')}
|
||||
description={t('dataset.retrieval.invertedIndex.description')}
|
||||
noRadio
|
||||
chosenConfig={
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.invertedIndex}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
description={t('dataset.retrieval.invertedIndex.description')} isActive>
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.invertedIndex}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</OptionCard>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -3,11 +3,9 @@ import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import RetrievalParamConfig from '../retrieval-param-config'
|
||||
import { OptionCard } from '../../create/step-two/option-card'
|
||||
import type { RetrievalConfig } from '@/types/app'
|
||||
import { RETRIEVE_METHOD } from '@/types/app'
|
||||
import RadioCard from '@/app/components/base/radio-card'
|
||||
import { PatternRecognition, Semantic } from '@/app/components/base/icons/src/vender/solid/development'
|
||||
import { FileSearch02 } from '@/app/components/base/icons/src/vender/solid/files'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
@ -16,6 +14,8 @@ import {
|
||||
RerankingModeEnum,
|
||||
WeightedScoreEnum,
|
||||
} from '@/models/datasets'
|
||||
import { PatternRecognition, Semantic } from '@/app/components/base/icons/src/vender/solid/development'
|
||||
import { FileSearch02 } from '@/app/components/base/icons/src/vender/solid/files'
|
||||
|
||||
type Props = {
|
||||
value: RetrievalConfig
|
||||
@ -56,67 +56,66 @@ const RetrievalMethodConfig: FC<Props> = ({
|
||||
return (
|
||||
<div className='space-y-2'>
|
||||
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
|
||||
<RadioCard
|
||||
icon={<Semantic className='w-4 h-4 text-[#7839EE]' />}
|
||||
<OptionCard icon={<Semantic className='w-4 h-4 text-[#7839EE]' />}
|
||||
title={t('dataset.retrieval.semantic_search.title')}
|
||||
description={t('dataset.retrieval.semantic_search.description')}
|
||||
isChosen={value.search_method === RETRIEVE_METHOD.semantic}
|
||||
onChosen={() => onChange({
|
||||
isActive={
|
||||
value.search_method === RETRIEVE_METHOD.semantic
|
||||
}
|
||||
onClick={() => onChange({
|
||||
...value,
|
||||
search_method: RETRIEVE_METHOD.semantic,
|
||||
})}
|
||||
chosenConfig={
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.semantic}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
>
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.semantic}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</OptionCard>
|
||||
)}
|
||||
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
|
||||
<RadioCard
|
||||
icon={<FileSearch02 className='w-4 h-4 text-[#7839EE]' />}
|
||||
<OptionCard icon={<FileSearch02 className='w-4 h-4 text-[#7839EE]' />}
|
||||
title={t('dataset.retrieval.full_text_search.title')}
|
||||
description={t('dataset.retrieval.full_text_search.description')}
|
||||
isChosen={value.search_method === RETRIEVE_METHOD.fullText}
|
||||
onChosen={() => onChange({
|
||||
isActive={
|
||||
value.search_method === RETRIEVE_METHOD.fullText
|
||||
}
|
||||
onClick={() => onChange({
|
||||
...value,
|
||||
search_method: RETRIEVE_METHOD.fullText,
|
||||
})}
|
||||
chosenConfig={
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.fullText}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
>
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.fullText}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</OptionCard>
|
||||
)}
|
||||
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
|
||||
<RadioCard
|
||||
icon={<PatternRecognition className='w-4 h-4 text-[#7839EE]' />}
|
||||
<OptionCard icon={<PatternRecognition className='w-4 h-4 text-[#7839EE]' />}
|
||||
title={
|
||||
<div className='flex items-center space-x-1'>
|
||||
<div>{t('dataset.retrieval.hybrid_search.title')}</div>
|
||||
<div className='flex h-full items-center px-1.5 rounded-md border border-[#E0EAFF] text-xs font-medium text-[#444CE7]'>{t('dataset.retrieval.hybrid_search.recommend')}</div>
|
||||
</div>
|
||||
}
|
||||
description={t('dataset.retrieval.hybrid_search.description')}
|
||||
isChosen={value.search_method === RETRIEVE_METHOD.hybrid}
|
||||
onChosen={() => onChange({
|
||||
description={t('dataset.retrieval.hybrid_search.description')} isActive={
|
||||
value.search_method === RETRIEVE_METHOD.hybrid
|
||||
}
|
||||
onClick={() => onChange({
|
||||
...value,
|
||||
search_method: RETRIEVE_METHOD.hybrid,
|
||||
reranking_enable: true,
|
||||
})}
|
||||
chosenConfig={
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.hybrid}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
>
|
||||
<RetrievalParamConfig
|
||||
type={RETRIEVE_METHOD.hybrid}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</OptionCard>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
} from '@/models/datasets'
|
||||
import WeightedScore from '@/app/components/app/configuration/dataset-config/params-config/weighted-score'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import RadioCard from '@/app/components/base/radio-card'
|
||||
|
||||
type Props = {
|
||||
type: RETRIEVE_METHOD
|
||||
@ -201,24 +202,18 @@ const RetrievalParamConfig: FC<Props> = ({
|
||||
{
|
||||
isHybridSearch && (
|
||||
<>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex gap-2 mb-4'>
|
||||
{
|
||||
rerankingModeOptions.map(option => (
|
||||
<div
|
||||
<RadioCard
|
||||
key={option.value}
|
||||
className={cn(
|
||||
'flex items-center justify-center mb-4 w-[calc((100%-8px)/2)] h-8 rounded-lg border border-components-option-card-option-border bg-components-option-card-option-bg cursor-pointer system-sm-medium text-text-secondary',
|
||||
value.reranking_mode === RerankingModeEnum.WeightedScore && option.value === RerankingModeEnum.WeightedScore && 'border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg text-text-primary',
|
||||
value.reranking_mode !== RerankingModeEnum.WeightedScore && option.value !== RerankingModeEnum.WeightedScore && 'border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg text-text-primary',
|
||||
)}
|
||||
onClick={() => handleChangeRerankMode(option.value)}
|
||||
>
|
||||
<div className='truncate'>{option.label}</div>
|
||||
<Tooltip
|
||||
popupContent={<div className='w-[200px]'>{option.tips}</div>}
|
||||
triggerClassName='ml-0.5 w-3.5 h-3.5'
|
||||
/>
|
||||
</div>
|
||||
isChosen={value.reranking_mode === option.value}
|
||||
onChosen={() => handleChangeRerankMode(option.value)}
|
||||
icon={<div className='w-4 h-4 text-[#7839EE]' />}
|
||||
title={option.label}
|
||||
description={option.tips}
|
||||
className='flex-1'
|
||||
/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user