Revert "Feat/parent child retrieval" (#12095)

This commit is contained in:
-LAN-
2024-12-25 20:55:44 +08:00
committed by GitHub
parent 9231fdbf4c
commit db2aa83a7c
216 changed files with 3116 additions and 9066 deletions

View File

@@ -1,29 +0,0 @@
'use client'
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
import { GeneralType, ParentChildType } from '@/app/components/base/icons/src/public/knowledge'
type Props = {
isGeneralMode: boolean
isQAMode: boolean
}
const ChunkingModeLabel: FC<Props> = ({
isGeneralMode,
isQAMode,
}) => {
const { t } = useTranslation()
const TypeIcon = isGeneralMode ? GeneralType : ParentChildType
return (
<Badge>
<div className='flex items-center h-full space-x-0.5 text-text-tertiary'>
<TypeIcon className='w-3 h-3' />
<span className='system-2xs-medium-uppercase'>{isGeneralMode ? `${t('dataset.chunkingMode.general')}${isQAMode ? ' · QA' : ''}` : t('dataset.chunkingMode.parentChild')}</span>
</div>
</Badge>
)
}
export default React.memo(ChunkingModeLabel)

View File

@@ -1,40 +0,0 @@
'use client'
import type { FC } from 'react'
import React from 'react'
import FileTypeIcon from '../../base/file-uploader/file-type-icon'
import type { FileAppearanceType } from '@/app/components/base/file-uploader/types'
import { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
const extendToFileTypeMap: { [key: string]: FileAppearanceType } = {
pdf: FileAppearanceTypeEnum.pdf,
json: FileAppearanceTypeEnum.document,
html: FileAppearanceTypeEnum.document,
txt: FileAppearanceTypeEnum.document,
markdown: FileAppearanceTypeEnum.markdown,
md: FileAppearanceTypeEnum.markdown,
xlsx: FileAppearanceTypeEnum.excel,
xls: FileAppearanceTypeEnum.excel,
csv: FileAppearanceTypeEnum.excel,
doc: FileAppearanceTypeEnum.word,
docx: FileAppearanceTypeEnum.word,
}
type Props = {
extension?: string
name?: string
size?: 'sm' | 'lg' | 'md'
className?: string
}
const DocumentFileIcon: FC<Props> = ({
extension,
name,
size = 'md',
className,
}) => {
const localExtension = extension?.toLowerCase() || name?.split('.')?.pop()?.toLowerCase()
return (
<FileTypeIcon type={extendToFileTypeMap[localExtension!] || FileAppearanceTypeEnum.document} size={size} className={className} />
)
}
export default React.memo(DocumentFileIcon)

View File

@@ -1,42 +0,0 @@
'use client'
import type { FC } from 'react'
import React, { useCallback } from 'react'
import FileIcon from '../document-file-icon'
import cn from '@/utils/classnames'
import type { DocumentItem } from '@/models/datasets'
type Props = {
className?: string
list: DocumentItem[]
onChange: (value: DocumentItem) => void
}
const DocumentList: FC<Props> = ({
className,
list,
onChange,
}) => {
const handleChange = useCallback((item: DocumentItem) => {
return () => onChange(item)
}, [onChange])
return (
<div className={cn(className)}>
{list.map((item) => {
const { id, name, extension } = item
return (
<div
key={id}
className='flex items-center h-8 px-2 hover:bg-state-base-hover rounded-lg space-x-2 cursor-pointer'
onClick={handleChange(item)}
>
<FileIcon name={item.name} extension={extension} size='md' />
<div className='truncate text-text-secondary text-sm'>{name}</div>
</div>
)
})}
</div>
)
}
export default React.memo(DocumentList)

View File

@@ -1,118 +0,0 @@
'use client'
import type { FC } from 'react'
import React, { useCallback, useState } from 'react'
import { useBoolean } from 'ahooks'
import { RiArrowDownSLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import FileIcon from '../document-file-icon'
import DocumentList from './document-list'
import type { DocumentItem, ParentMode, SimpleDocumentDetail } from '@/models/datasets'
import { ProcessMode } from '@/models/datasets'
import {
PortalToFollowElem,
PortalToFollowElemContent,
PortalToFollowElemTrigger,
} from '@/app/components/base/portal-to-follow-elem'
import cn from '@/utils/classnames'
import SearchInput from '@/app/components/base/search-input'
import { GeneralType, ParentChildType } from '@/app/components/base/icons/src/public/knowledge'
import { useDocumentList } from '@/service/knowledge/use-document'
import Loading from '@/app/components/base/loading'
type Props = {
datasetId: string
value: {
name?: string
extension?: string
processMode?: ProcessMode
parentMode?: ParentMode
}
onChange: (value: SimpleDocumentDetail) => void
}
const DocumentPicker: FC<Props> = ({
datasetId,
value,
onChange,
}) => {
const { t } = useTranslation()
const {
name,
extension,
processMode,
parentMode,
} = value
const [query, setQuery] = useState('')
const { data } = useDocumentList({
datasetId,
query: {
keyword: query,
page: 1,
limit: 20,
},
})
const documentsList = data?.data
const isParentChild = processMode === ProcessMode.parentChild
const TypeIcon = isParentChild ? ParentChildType : GeneralType
const [open, {
set: setOpen,
toggle: togglePopup,
}] = useBoolean(false)
const ArrowIcon = RiArrowDownSLine
const handleChange = useCallback(({ id }: DocumentItem) => {
onChange(documentsList?.find(item => item.id === id) as SimpleDocumentDetail)
setOpen(false)
}, [documentsList, onChange, setOpen])
return (
<PortalToFollowElem
open={open}
onOpenChange={setOpen}
placement='bottom-start'
>
<PortalToFollowElemTrigger onClick={togglePopup}>
<div className={cn('flex items-center ml-1 px-2 py-0.5 rounded-lg hover:bg-state-base-hover select-none cursor-pointer', open && 'bg-state-base-hover')}>
<FileIcon name={name} extension={extension} size='lg' />
<div className='flex flex-col items-start ml-1 mr-0.5'>
<div className='flex items-center space-x-0.5'>
<span className={cn('system-md-semibold')}> {name || '--'}</span>
<ArrowIcon className={'h-4 w-4 text-text-primary'} />
</div>
<div className='flex items-center h-3 text-text-tertiary space-x-0.5'>
<TypeIcon className='w-3 h-3' />
<span className={cn('system-2xs-medium-uppercase', isParentChild && 'mt-0.5' /* to icon problem cause not ver align */)}>
{isParentChild ? t('dataset.chunkingMode.parentChild') : t('dataset.chunkingMode.general')}
{isParentChild && ` · ${!parentMode ? '--' : parentMode === 'paragraph' ? t('dataset.parentMode.paragraph') : t('dataset.parentMode.fullDoc')}`}
</span>
</div>
</div>
</div>
</PortalToFollowElemTrigger>
<PortalToFollowElemContent className='z-[11]'>
<div className='w-[360px] p-1 pt-2 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]'>
<SearchInput value={query} onChange={setQuery} className='mx-1' />
{documentsList
? (
<DocumentList
className='mt-2'
list={documentsList.map(d => ({
id: d.id,
name: d.name,
extension: d.data_source_detail_dict?.upload_file?.extension || '',
}))}
onChange={handleChange}
/>
)
: (<div className='mt-2 flex items-center justify-center w-[360px] h-[100px]'>
<Loading />
</div>)}
</div>
</PortalToFollowElemContent>
</PortalToFollowElem>
)
}
export default React.memo(DocumentPicker)

View File

@@ -1,82 +0,0 @@
'use client'
import type { FC } from 'react'
import React, { useCallback } from 'react'
import { useBoolean } from 'ahooks'
import { RiArrowDownSLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import FileIcon from '../document-file-icon'
import DocumentList from './document-list'
import {
PortalToFollowElem,
PortalToFollowElemContent,
PortalToFollowElemTrigger,
} from '@/app/components/base/portal-to-follow-elem'
import cn from '@/utils/classnames'
import Loading from '@/app/components/base/loading'
import type { DocumentItem } from '@/models/datasets'
type Props = {
className?: string
value: DocumentItem
files: DocumentItem[]
onChange: (value: DocumentItem) => void
}
const PreviewDocumentPicker: FC<Props> = ({
className,
value,
files,
onChange,
}) => {
const { t } = useTranslation()
const { name, extension } = value
const [open, {
set: setOpen,
toggle: togglePopup,
}] = useBoolean(false)
const ArrowIcon = RiArrowDownSLine
const handleChange = useCallback((item: DocumentItem) => {
onChange(item)
setOpen(false)
}, [onChange, setOpen])
return (
<PortalToFollowElem
open={open}
onOpenChange={setOpen}
placement='bottom-start'
offset={4}
>
<PortalToFollowElemTrigger onClick={togglePopup}>
<div className={cn('flex items-center h-6 px-1 rounded-md hover:bg-state-base-hover select-none', open && 'bg-state-base-hover', className)}>
<FileIcon name={name} extension={extension} size='md' />
<div className='flex flex-col items-start ml-1'>
<div className='flex items-center space-x-0.5'>
<span className={cn('system-md-semibold max-w-[200px] truncate text-text-primary')}> {name || '--'}</span>
<ArrowIcon className={'h-[18px] w-[18px] text-text-primary'} />
</div>
</div>
</div>
</PortalToFollowElemTrigger>
<PortalToFollowElemContent className='z-[11]'>
<div className='w-[392px] p-1 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]'>
{files?.length > 1 && <div className='pl-2 flex items-center h-8 system-xs-medium-uppercase text-text-tertiary'>{t('dataset.preprocessDocument', { num: files.length })}</div>}
{files?.length > 0
? (
<DocumentList
list={files}
onChange={handleChange}
/>
)
: (<div className='mt-2 flex items-center justify-center w-[360px] h-[100px]'>
<Loading />
</div>)}
</div>
</PortalToFollowElemContent>
</PortalToFollowElem>
)
}
export default React.memo(PreviewDocumentPicker)

View File

@@ -1,38 +0,0 @@
'use client'
import type { FC } from 'react'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import StatusWithAction from './status-with-action'
import { useAutoDisabledDocuments, useDocumentEnable, useInvalidDisabledDocument } from '@/service/knowledge/use-document'
import Toast from '@/app/components/base/toast'
type Props = {
datasetId: string
}
const AutoDisabledDocument: FC<Props> = ({
datasetId,
}) => {
const { t } = useTranslation()
const { data, isLoading } = useAutoDisabledDocuments(datasetId)
const invalidDisabledDocument = useInvalidDisabledDocument()
const documentIds = data?.document_ids
const hasDisabledDocument = documentIds && documentIds.length > 0
const { mutateAsync: enableDocument } = useDocumentEnable()
const handleEnableDocuments = useCallback(async () => {
await enableDocument({ datasetId, documentIds })
invalidDisabledDocument()
Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
}, [])
if (!hasDisabledDocument || isLoading)
return null
return (
<StatusWithAction
type='info'
description={t('dataset.documentsDisabled', { num: documentIds?.length })}
actionText={t('dataset.enable')}
onAction={handleEnableDocuments}
/>
)
}
export default React.memo(AutoDisabledDocument)

View File

@@ -1,69 +0,0 @@
'use client'
import type { FC } from 'react'
import React, { useEffect, useReducer } from 'react'
import { useTranslation } from 'react-i18next'
import useSWR from 'swr'
import StatusWithAction from './status-with-action'
import { getErrorDocs, retryErrorDocs } from '@/service/datasets'
import type { IndexingStatusResponse } from '@/models/datasets'
type Props = {
datasetId: string
}
type IIndexState = {
value: string
}
type ActionType = 'retry' | 'success' | 'error'
type IAction = {
type: ActionType
}
const indexStateReducer = (state: IIndexState, action: IAction) => {
const actionMap = {
retry: 'retry',
success: 'success',
error: 'error',
}
return {
...state,
value: actionMap[action.type] || state.value,
}
}
const RetryButton: FC<Props> = ({ datasetId }) => {
const { t } = useTranslation()
const [indexState, dispatch] = useReducer(indexStateReducer, { value: 'success' })
const { data: errorDocs, isLoading } = useSWR({ datasetId }, getErrorDocs)
const onRetryErrorDocs = async () => {
dispatch({ type: 'retry' })
const document_ids = errorDocs?.data.map((doc: IndexingStatusResponse) => doc.id) || []
const res = await retryErrorDocs({ datasetId, document_ids })
if (res.result === 'success')
dispatch({ type: 'success' })
else
dispatch({ type: 'error' })
}
useEffect(() => {
if (errorDocs?.total === 0)
dispatch({ type: 'success' })
else
dispatch({ type: 'error' })
}, [errorDocs?.total])
if (isLoading || indexState.value === 'success')
return null
return (
<StatusWithAction
type='warning'
description={`${errorDocs?.total} ${t('dataset.docsFailedNotice')}`}
actionText={t('dataset.retry')}
disabled={indexState.value === 'retry'}
onAction={indexState.value === 'error' ? onRetryErrorDocs : () => { }}
/>
)
}
export default RetryButton

View File

@@ -1,65 +0,0 @@
'use client'
import { RiAlertFill, RiCheckboxCircleFill, RiErrorWarningFill, RiInformation2Fill } from '@remixicon/react'
import type { FC } from 'react'
import React from 'react'
import cn from '@/utils/classnames'
import Divider from '@/app/components/base/divider'
type Status = 'success' | 'error' | 'warning' | 'info'
type Props = {
type?: Status
description: string
actionText: string
onAction: () => void
disabled?: boolean
}
const IconMap = {
success: {
Icon: RiCheckboxCircleFill,
color: 'text-text-success',
},
error: {
Icon: RiErrorWarningFill,
color: 'text-text-destructive',
},
warning: {
Icon: RiAlertFill,
color: 'text-text-warning-secondary',
},
info: {
Icon: RiInformation2Fill,
color: 'text-text-accent',
},
}
const getIcon = (type: Status) => {
return IconMap[type]
}
const StatusAction: FC<Props> = ({
type = 'info',
description,
actionText,
onAction,
disabled,
}) => {
const { Icon, color } = getIcon(type)
return (
<div className='relative flex items-center h-[34px] rounded-lg pl-2 pr-3 border border-components-panel-border bg-components-panel-bg-blur shadow-xs'>
<div className={`absolute inset-0 opacity-40 rounded-lg ${(type === 'success' && 'bg-[linear-gradient(92deg,rgba(23,178,106,0.25)_0%,rgba(255,255,255,0.00)_100%)]')
|| (type === 'warning' && 'bg-[linear-gradient(92deg,rgba(247,144,9,0.25)_0%,rgba(255,255,255,0.00)_100%)]')
|| (type === 'error' && 'bg-[linear-gradient(92deg,rgba(240,68,56,0.25)_0%,rgba(255,255,255,0.00)_100%)]')
|| (type === 'info' && 'bg-[linear-gradient(92deg,rgba(11,165,236,0.25)_0%,rgba(255,255,255,0.00)_100%)]')
}`}
/>
<div className='relative z-10 flex h-full items-center space-x-2'>
<Icon className={cn('w-4 h-4', color)} />
<div className='text-[13px] font-normal text-text-secondary'>{description}</div>
<Divider type='vertical' className='!h-4' />
<div onClick={onAction} className={cn('text-text-accent font-semibold text-[13px] cursor-pointer', disabled && 'text-text-disabled cursor-not-allowed')}>{actionText}</div>
</div>
</div>
)
}
export default React.memo(StatusAction)

View File

@@ -2,11 +2,10 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import Image from 'next/image'
import RetrievalParamConfig from '../retrieval-param-config'
import { OptionCard } from '../../create/step-two/option-card'
import { retrievalIcon } from '../../create/icons'
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'
type Props = {
@@ -22,17 +21,19 @@ const EconomicalRetrievalMethodConfig: FC<Props> = ({
return (
<div className='space-y-2'>
<OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.vector} alt='' />}
<RadioCard
icon={<HighPriority className='w-4 h-4 text-[#7839EE]' />}
title={t('dataset.retrieval.invertedIndex.title')}
description={t('dataset.retrieval.invertedIndex.description')} isActive
activeHeaderClassName='bg-dataset-option-card-purple-gradient'
>
<RetrievalParamConfig
type={RETRIEVE_METHOD.invertedIndex}
value={value}
onChange={onChange}
/>
</OptionCard>
description={t('dataset.retrieval.invertedIndex.description')}
noRadio
chosenConfig={
<RetrievalParamConfig
type={RETRIEVE_METHOD.invertedIndex}
value={value}
onChange={onChange}
/>
}
/>
</div>
)
}

View File

@@ -2,13 +2,12 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import Image from 'next/image'
import RetrievalParamConfig from '../retrieval-param-config'
import { OptionCard } from '../../create/step-two/option-card'
import Effect from '../../create/assets/option-card-effect-purple.svg'
import { retrievalIcon } from '../../create/icons'
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'
@@ -17,7 +16,6 @@ import {
RerankingModeEnum,
WeightedScoreEnum,
} from '@/models/datasets'
import Badge from '@/app/components/base/badge'
type Props = {
value: RetrievalConfig
@@ -58,72 +56,67 @@ const RetrievalMethodConfig: FC<Props> = ({
return (
<div className='space-y-2'>
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
<OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.vector} alt='' />}
<RadioCard
icon={<Semantic className='w-4 h-4 text-[#7839EE]' />}
title={t('dataset.retrieval.semantic_search.title')}
description={t('dataset.retrieval.semantic_search.description')}
isActive={
value.search_method === RETRIEVE_METHOD.semantic
}
onSwitched={() => onChange({
isChosen={value.search_method === RETRIEVE_METHOD.semantic}
onChosen={() => onChange({
...value,
search_method: RETRIEVE_METHOD.semantic,
})}
effectImg={Effect.src}
activeHeaderClassName='bg-dataset-option-card-purple-gradient'
>
<RetrievalParamConfig
type={RETRIEVE_METHOD.semantic}
value={value}
onChange={onChange}
/>
</OptionCard>
chosenConfig={
<RetrievalParamConfig
type={RETRIEVE_METHOD.semantic}
value={value}
onChange={onChange}
/>
}
/>
)}
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
<OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.fullText} alt='' />}
<RadioCard
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')}
isActive={
value.search_method === RETRIEVE_METHOD.fullText
}
onSwitched={() => onChange({
isChosen={value.search_method === RETRIEVE_METHOD.fullText}
onChosen={() => onChange({
...value,
search_method: RETRIEVE_METHOD.fullText,
})}
effectImg={Effect.src}
activeHeaderClassName='bg-dataset-option-card-purple-gradient'
>
<RetrievalParamConfig
type={RETRIEVE_METHOD.fullText}
value={value}
onChange={onChange}
/>
</OptionCard>
chosenConfig={
<RetrievalParamConfig
type={RETRIEVE_METHOD.fullText}
value={value}
onChange={onChange}
/>
}
/>
)}
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (
<OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.hybrid} alt='' />}
<RadioCard
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>
<Badge text={t('dataset.retrieval.hybrid_search.recommend')!} className='border-text-accent-secondary text-text-accent-secondary ml-1 h-[18px]' uppercase />
<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')} isActive={
value.search_method === RETRIEVE_METHOD.hybrid
}
onSwitched={() => onChange({
description={t('dataset.retrieval.hybrid_search.description')}
isChosen={value.search_method === RETRIEVE_METHOD.hybrid}
onChosen={() => onChange({
...value,
search_method: RETRIEVE_METHOD.hybrid,
reranking_enable: true,
})}
effectImg={Effect.src}
activeHeaderClassName='bg-dataset-option-card-purple-gradient'
>
<RetrievalParamConfig
type={RETRIEVE_METHOD.hybrid}
value={value}
onChange={onChange}
/>
</OptionCard>
chosenConfig={
<RetrievalParamConfig
type={RETRIEVE_METHOD.hybrid}
value={value}
onChange={onChange}
/>
}
/>
)}
</div>
)

View File

@@ -2,11 +2,12 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import Image from 'next/image'
import { retrievalIcon } from '../../create/icons'
import type { RetrievalConfig } from '@/types/app'
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 { 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
@@ -14,12 +15,11 @@ type Props = {
export const getIcon = (type: RETRIEVE_METHOD) => {
return ({
[RETRIEVE_METHOD.semantic]: retrievalIcon.vector,
[RETRIEVE_METHOD.fullText]: retrievalIcon.fullText,
[RETRIEVE_METHOD.hybrid]: retrievalIcon.hybrid,
[RETRIEVE_METHOD.invertedIndex]: retrievalIcon.vector,
[RETRIEVE_METHOD.keywordSearch]: retrievalIcon.vector,
})[type] || retrievalIcon.vector
[RETRIEVE_METHOD.semantic]: Semantic,
[RETRIEVE_METHOD.fullText]: FileSearch02,
[RETRIEVE_METHOD.hybrid]: PatternRecognition,
[RETRIEVE_METHOD.invertedIndex]: HighPriority,
})[type] || FileSearch02
}
const EconomicalRetrievalMethodConfig: FC<Props> = ({
@@ -28,11 +28,11 @@ const EconomicalRetrievalMethodConfig: FC<Props> = ({
}) => {
const { t } = useTranslation()
const type = value.search_method
const icon = <Image className='size-3.5 text-util-colors-purple-purple-600' src={getIcon(type)} alt='' />
const Icon = getIcon(type)
return (
<div className='space-y-2'>
<RadioCard
icon={icon}
icon={<Icon className='w-4 h-4 text-[#7839EE]' />}
title={t(`dataset.retrieval.${type}.title`)}
description={t(`dataset.retrieval.${type}.description`)}
noRadio

View File

@@ -3,9 +3,6 @@ import type { FC } from 'react'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import Image from 'next/image'
import ProgressIndicator from '../../create/assets/progress-indicator.svg'
import Reranking from '../../create/assets/rerank.svg'
import cn from '@/utils/classnames'
import TopKItem from '@/app/components/base/param-item/top-k-item'
import ScoreThresholdItem from '@/app/components/base/param-item/score-threshold-item'
@@ -23,7 +20,6 @@ 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
@@ -120,7 +116,7 @@ const RetrievalParamConfig: FC<Props> = ({
<div>
{!isEconomical && !isHybridSearch && (
<div>
<div className='flex items-center space-x-2 mb-2'>
<div className='flex h-8 items-center text-[13px] font-medium text-gray-900 space-x-2'>
{canToggleRerankModalEnable && (
<div
className='flex items-center'
@@ -140,7 +136,7 @@ const RetrievalParamConfig: FC<Props> = ({
</div>
)}
<div className='flex items-center'>
<span className='mr-0.5 system-sm-semibold text-text-secondary'>{t('common.modelProvider.rerankModel.key')}</span>
<span className='mr-0.5'>{t('common.modelProvider.rerankModel.key')}</span>
<Tooltip
popupContent={
<div className="w-[200px]">{t('common.modelProvider.rerankModel.tip')}</div>
@@ -167,7 +163,7 @@ const RetrievalParamConfig: FC<Props> = ({
)}
{
!isHybridSearch && (
<div className={cn(!isEconomical && 'mt-4', 'flex space-between space-x-4')}>
<div className={cn(!isEconomical && 'mt-4', 'flex space-between space-x-6')}>
<TopKItem
className='grow'
value={value.top_k}
@@ -205,22 +201,24 @@ const RetrievalParamConfig: FC<Props> = ({
{
isHybridSearch && (
<>
<div className='flex gap-2 mb-4'>
<div className='flex items-center justify-between'>
{
rerankingModeOptions.map(option => (
<RadioCard
<div
key={option.value}
isChosen={value.reranking_mode === option.value}
onChosen={() => handleChangeRerankMode(option.value)}
icon={<Image src={
option.value === RerankingModeEnum.WeightedScore
? ProgressIndicator
: Reranking
} alt=''/>}
title={option.label}
description={option.tips}
className='flex-1'
/>
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>
))
}
</div>