merge feat/plugins

This commit is contained in:
zxhlyh
2024-12-27 14:21:32 +08:00
324 changed files with 15188 additions and 8023 deletions

View File

@ -29,17 +29,17 @@ const ChunkDetailModal: FC<Props> = ({
const { position, content, keywords, document } = segment
const isParentChildRetrieval = !!(child_chunks && child_chunks.length > 0)
const extension = document.name.split('.').slice(-1)[0] as FileAppearanceTypeEnum
const maxHeighClassName = 'max-h-[min(752px,_80vh)] overflow-y-auto'
const heighClassName = isParentChildRetrieval ? 'h-[min(627px,_80vh)] overflow-y-auto' : 'h-[min(539px,_80vh)] overflow-y-auto'
return (
<Modal
title={t(`${i18nPrefix}.chunkDetail`)}
isShow
closable
onClose={onHide}
className={cn(isParentChildRetrieval ? '!min-w-[1200px]' : '!min-w-[720px]')}
className={cn(isParentChildRetrieval ? '!min-w-[1200px]' : '!min-w-[800px]')}
>
<div className='mt-4 flex'>
<div className='w-full'>
<div className={cn('flex-1', isParentChildRetrieval && 'pr-6')}>
{/* Meta info */}
<div className='flex justify-between items-center'>
<div className='grow flex items-center space-x-2'>
@ -56,7 +56,7 @@ const ChunkDetailModal: FC<Props> = ({
</div>
<Score value={score} />
</div>
<div className={cn('mt-2 body-md-regular text-text-secondary', maxHeighClassName)}>
<div className={cn('mt-2 body-md-regular text-text-secondary', heighClassName)}>
{content}
</div>
{!isParentChildRetrieval && keywords && keywords.length > 0 && (
@ -72,9 +72,9 @@ const ChunkDetailModal: FC<Props> = ({
</div>
{isParentChildRetrieval && (
<div className='shrink-0 w-[552px] px-6'>
<div className='flex-1 pl-6 pb-6'>
<div className='system-xs-semibold-uppercase text-text-secondary'>{t(`${i18nPrefix}.hitChunks`, { num: child_chunks.length })}</div>
<div className={cn('mt-1 space-y-2', maxHeighClassName)}>
<div className={cn('mt-1 space-y-2', heighClassName)}>
{child_chunks.map(item => (
<ChildChunksItem key={item.id} payload={item} isShowAll />
))}

View File

@ -14,6 +14,7 @@ import cn from '@/utils/classnames'
import FileIcon from '@/app/components/base/file-uploader/file-type-icon'
import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
import Tag from '@/app/components/datasets/documents/detail/completed/common/tag'
import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'
const i18nPrefix = 'datasetHitTesting'
type Props = {
@ -31,6 +32,7 @@ const ResultItem: FC<Props> = ({
const { position, word_count, content, keywords, document } = data
const isParentChildRetrieval = !!(child_chunks && child_chunks.length > 0)
const extension = document.name.split('.').slice(-1)[0] as FileAppearanceTypeEnum
const fileType = extensionToFileType(extension)
const [isFold, {
toggle: toggleFold,
}] = useBoolean(false)
@ -41,8 +43,13 @@ const ResultItem: FC<Props> = ({
setFalse: hideDetailModal,
}] = useBoolean(false)
const handleClickCard = () => {
if (!isParentChildRetrieval)
showDetailModal()
}
return (
<div className='pt-3 bg-chat-bubble-bg rounded-xl hover:shadow-lg'>
<div className={cn('pt-3 bg-chat-bubble-bg rounded-xl hover:shadow-lg', !isParentChildRetrieval && 'cursor-pointer')} onClick={handleClickCard}>
{/* Meta info */}
<div className='flex justify-between items-center px-3'>
<div className='flex items-center space-x-2'>
@ -88,7 +95,7 @@ const ResultItem: FC<Props> = ({
{/* Foot */}
<div className='mt-3 flex justify-between items-center h-10 pl-3 pr-2 border-t border-divider-subtle'>
<div className='grow flex items-center space-x-1'>
<FileIcon type={extension} size='sm' />
<FileIcon type={fileType} size='sm' />
<span className='grow w-0 truncate text-text-secondary text-[13px] font-normal'>{document.name}</span>
</div>
<div

View File

@ -11,6 +11,7 @@ import EconomicalRetrievalMethodConfig from '@/app/components/datasets/common/ec
import Button from '@/app/components/base/button'
import { ensureRerankModelSelected, isReRankModelSelected } from '@/app/components/datasets/common/check-rerank-model'
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { RerankingModeEnum } from '@/models/datasets'
type Props = {
indexMethod: string
@ -57,7 +58,10 @@ const ModifyRetrievalModal: FC<Props> = ({
}
onSave(ensureRerankModelSelected({
rerankDefaultModel: rerankDefaultModel!,
retrievalConfig,
retrievalConfig: {
...retrievalConfig,
reranking_enable: retrievalConfig.reranking_mode === RerankingModeEnum.RerankingModel,
},
indexMethod,
}))
}

View File

@ -0,0 +1,31 @@
import { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
export const extensionToFileType = (extension: string): FileAppearanceTypeEnum => {
switch (extension) {
case 'pdf':
return FileAppearanceTypeEnum.pdf
case 'doc':
case 'docx':
return FileAppearanceTypeEnum.word
case 'txt':
case 'epub':
return FileAppearanceTypeEnum.document
case 'md':
case 'mdx':
case 'markdown':
return FileAppearanceTypeEnum.markdown
case 'csv':
case 'xls':
case 'xlsx':
return FileAppearanceTypeEnum.excel
case 'html':
case 'htm':
case 'xml':
return FileAppearanceTypeEnum.document
case 'ppt':
case 'pptx':
return FileAppearanceTypeEnum.ppt
default:
return FileAppearanceTypeEnum.custom
}
}