mirror of
https://github.com/langgenius/dify.git
synced 2026-04-15 01:38:19 +08:00
Merge branch 'feat/parent-child-retrieval' of https://github.com/langgenius/dify into feat/parent-child-retrieval
This commit is contained in:
commit
12c791149c
@ -75,6 +75,10 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.indexItem.disabled:hover {
|
||||
background-color: #fcfcfd;
|
||||
border-color: #f2f4f7;
|
||||
|
||||
@ -177,6 +177,8 @@ const StepTwo = ({
|
||||
setDocForm(value)
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
currentEstimateMutation.reset()
|
||||
if (value === ChuckingMode.parentChild)
|
||||
setIndexType(IndexingType.QUALIFIED)
|
||||
}
|
||||
|
||||
const [docLanguage, setDocLanguage] = useState<string>(
|
||||
@ -503,6 +505,9 @@ const StepTwo = ({
|
||||
}
|
||||
|
||||
const changeToEconomicalType = () => {
|
||||
if (docForm === ChuckingMode.parentChild)
|
||||
return
|
||||
|
||||
if (!hasSetIndexType) {
|
||||
setIndexType(IndexingType.ECONOMICAL)
|
||||
if (docForm === ChuckingMode.qa)
|
||||
@ -555,8 +560,12 @@ const StepTwo = ({
|
||||
icon={<Image src={SettingCog} alt={t('datasetCreation.stepTwo.general')} />}
|
||||
activeHeaderClassName='bg-gradient-to-r from-[#EFF0F9] to-[#F9FAFB]'
|
||||
description={t('datasetCreation.stepTwo.generalTip')}
|
||||
isActive={docForm === ChuckingMode.qa || docForm === ChuckingMode.text}
|
||||
onSelect={() => handleChangeDocform(ChuckingMode.text)}
|
||||
isActive={
|
||||
[ChuckingMode.text, ChuckingMode.qa].includes(docForm)
|
||||
}
|
||||
onSwitched={() =>
|
||||
handleChangeDocform(ChuckingMode.text)
|
||||
}
|
||||
actions={
|
||||
<>
|
||||
<Button variant={'secondary-accent'} onClick={() => updatePreview()}>
|
||||
@ -651,7 +660,7 @@ const StepTwo = ({
|
||||
activeHeaderClassName='bg-gradient-to-r from-[#F9F1EE] to-[#F9FAFB]'
|
||||
description={t('datasetCreation.stepTwo.parentChildTip')}
|
||||
isActive={docForm === ChuckingMode.parentChild}
|
||||
onSelected={() => handleChangeDocform(ChuckingMode.parentChild)}
|
||||
onSwitched={() => handleChangeDocform(ChuckingMode.parentChild)}
|
||||
actions={
|
||||
<>
|
||||
<Button variant={'secondary-accent'} onClick={() => updatePreview()}>
|
||||
@ -815,6 +824,7 @@ const StepTwo = ({
|
||||
!hasSetIndexType && indexType === IndexingType.ECONOMICAL && s.active,
|
||||
hasSetIndexType && s.disabled,
|
||||
hasSetIndexType && '!w-full !min-h-[96px]',
|
||||
docForm === ChuckingMode.parentChild && s.disabled,
|
||||
)}
|
||||
onClick={changeToEconomicalType}
|
||||
>
|
||||
@ -919,7 +929,10 @@ const StepTwo = ({
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<DocumentPicker datasetId={datasetId || ''} value={{}} onChange={console.log} />
|
||||
<Badge text='276 Estimated chunks' />
|
||||
<Badge text={t(
|
||||
'datasetCreation.stepTwo.previewChunkCount', {
|
||||
count: estimate?.preview.length || estimate?.qa_preview?.length || 0,
|
||||
}) as string} />
|
||||
</div>
|
||||
</PreviewHeader>}
|
||||
className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll')}
|
||||
@ -971,7 +984,9 @@ const StepTwo = ({
|
||||
<div className='h-full w-full flex items-center justify-center'>
|
||||
<div className='flex flex-col items-center justify-center gap-3'>
|
||||
<RiSearchEyeLine className='size-10 text-text-empty-state-icon' />
|
||||
<p className='text-sm text-text-tertiary'>{'Click the \'Preview Chunk\' button on the left to load the preview'}</p>
|
||||
<p className='text-sm text-text-tertiary'>
|
||||
{t('datasetCreation.stepTwo.previewChunkTip')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -22,7 +22,7 @@ type OptionCardHeaderProps = {
|
||||
export const OptionCardHeader: FC<OptionCardHeaderProps> = (props) => {
|
||||
const { icon, title, description, isActive, activeClassName, effectImg } = props
|
||||
return <div className={classNames(
|
||||
'flex h-full overflow-hidden rounded-xl relative',
|
||||
'flex h-full overflow-hidden rounded-t-xl relative',
|
||||
isActive && activeClassName,
|
||||
)}>
|
||||
<div className='size-14 flex items-center justify-center relative overflow-hidden'>
|
||||
@ -50,11 +50,11 @@ type OptionCardProps = {
|
||||
isActive?: boolean
|
||||
actions?: ReactNode
|
||||
effectImg?: string
|
||||
onSelected?: () => void
|
||||
onSwitched?: () => void
|
||||
} & Omit<ComponentProps<'div'>, 'title'>
|
||||
|
||||
export const OptionCard: FC<OptionCardProps> = (props) => {
|
||||
const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSelected, onClick, ...rest } = props
|
||||
const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSwitched, onClick, ...rest } = props
|
||||
return <div
|
||||
className={classNames(
|
||||
'rounded-xl',
|
||||
@ -67,7 +67,7 @@ export const OptionCard: FC<OptionCardProps> = (props) => {
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (!isActive)
|
||||
onSelected?.()
|
||||
onSwitched?.()
|
||||
onClick?.(e)
|
||||
}}
|
||||
{...rest}>
|
||||
|
||||
@ -164,6 +164,8 @@ const translation = {
|
||||
indexSettingTip: 'To change the index method & embedding model, please go to the ',
|
||||
retrievalSettingTip: 'To change the retrieval setting, please go to the ',
|
||||
datasetSettingLink: 'Knowledge settings.',
|
||||
previewChunkTip: 'Click the \'Preview Chunk\' button on the left to load the preview',
|
||||
previewChunkCount: '{{count}} Estimated chunks',
|
||||
},
|
||||
stepThree: {
|
||||
creationTitle: '🎉 Knowledge created',
|
||||
|
||||
@ -164,6 +164,8 @@ const translation = {
|
||||
indexSettingTip: '要更改索引方法和 embedding 模型,请转到',
|
||||
retrievalSettingTip: '要更改检索方法,请转到',
|
||||
datasetSettingLink: '知识库设置。',
|
||||
previewChunkTip: '点击左侧的“预览块”按钮来加载预览',
|
||||
previewChunkCount: '{{count}} 预估块',
|
||||
},
|
||||
stepThree: {
|
||||
creationTitle: '🎉 知识库已创建',
|
||||
|
||||
@ -35,7 +35,7 @@ const toBatchDocumentsIdParams = (documentIds: string[] | string) => {
|
||||
export const useDocumentBatchAction = (action: DocumentActionType) => {
|
||||
return useMutation({
|
||||
mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => {
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/status/${action}?${toBatchDocumentsIdParams(documentId || documentIds!)}`)
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/status/${action}/batch?${toBatchDocumentsIdParams(documentId || documentIds!)}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -59,7 +59,7 @@ export const useDocumentUnArchive = () => {
|
||||
export const useDocumentDelete = () => {
|
||||
return useMutation({
|
||||
mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => {
|
||||
return del<CommonResponse>(`/datasets/${datasetId}/documents?${toBatchDocumentsIdParams(documentId || documentIds!)}`)
|
||||
return del<CommonResponse>(`/datasets/${datasetId}/documents/batch?${toBatchDocumentsIdParams(documentId || documentIds!)}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user