diff --git a/web/app/components/base/icons/assets/vender/knowledge/search-lines-sparkle.svg b/web/app/components/base/icons/assets/vender/knowledge/search-lines-sparkle.svg new file mode 100644 index 0000000000..1eb2781715 --- /dev/null +++ b/web/app/components/base/icons/assets/vender/knowledge/search-lines-sparkle.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.json b/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.json new file mode 100644 index 0000000000..7fa195092d --- /dev/null +++ b/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.json @@ -0,0 +1,53 @@ +{ + "icon": { + "type": "element", + "isRootNode": true, + "name": "svg", + "attributes": { + "width": "16", + "height": "16", + "viewBox": "0 0 16 16", + "fill": "none", + "xmlns": "http://www.w3.org/2000/svg" + }, + "children": [ + { + "type": "element", + "name": "path", + "attributes": { + "d": "M12 7.33337V2.66671H4.00002V13.3334H8.00002C8.36821 13.3334 8.66669 13.6319 8.66669 14C8.66669 14.3682 8.36821 14.6667 8.00002 14.6667H3.33335C2.96516 14.6667 2.66669 14.3682 2.66669 14V2.00004C2.66669 1.63185 2.96516 1.33337 3.33335 1.33337H12.6667C13.0349 1.33337 13.3334 1.63185 13.3334 2.00004V7.33337C13.3334 7.70156 13.0349 8.00004 12.6667 8.00004C12.2985 8.00004 12 7.70156 12 7.33337Z", + "fill": "currentColor" + }, + "children": [] + }, + { + "type": "element", + "name": "path", + "attributes": { + "d": "M10 4.00004C10.3682 4.00004 10.6667 4.29852 10.6667 4.66671C10.6667 5.0349 10.3682 5.33337 10 5.33337H6.00002C5.63183 5.33337 5.33335 5.0349 5.33335 4.66671C5.33335 4.29852 5.63183 4.00004 6.00002 4.00004H10Z", + "fill": "currentColor" + }, + "children": [] + }, + { + "type": "element", + "name": "path", + "attributes": { + "d": "M8.00002 6.66671C8.36821 6.66671 8.66669 6.96518 8.66669 7.33337C8.66669 7.70156 8.36821 8.00004 8.00002 8.00004H6.00002C5.63183 8.00004 5.33335 7.70156 5.33335 7.33337C5.33335 6.96518 5.63183 6.66671 6.00002 6.66671H8.00002Z", + "fill": "currentColor" + }, + "children": [] + }, + { + "type": "element", + "name": "path", + "attributes": { + "d": "M12.827 10.7902L12.3624 9.58224C12.3048 9.43231 12.1607 9.33337 12 9.33337C11.8394 9.33337 11.6953 9.43231 11.6376 9.58224L11.173 10.7902C11.1054 10.9662 10.9662 11.1054 10.7902 11.173L9.58222 11.6376C9.43229 11.6953 9.33335 11.8394 9.33335 12C9.33335 12.1607 9.43229 12.3048 9.58222 12.3624L10.7902 12.827C10.9662 12.8947 11.1054 13.0338 11.173 13.2099L11.6376 14.4178C11.6953 14.5678 11.8394 14.6667 12 14.6667C12.1607 14.6667 12.3048 14.5678 12.3624 14.4178L12.827 13.2099C12.8947 13.0338 13.0338 12.8947 13.2099 12.827L14.4178 12.3624C14.5678 12.3048 14.6667 12.1607 14.6667 12C14.6667 11.8394 14.5678 11.6953 14.4178 11.6376L13.2099 11.173C13.0338 11.1054 12.8947 10.9662 12.827 10.7902Z", + "fill": "currentColor" + }, + "children": [] + } + ] + }, + "name": "SearchLinesSparkle" +} diff --git a/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.tsx b/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.tsx new file mode 100644 index 0000000000..3ae90b5fa1 --- /dev/null +++ b/web/app/components/base/icons/src/vender/knowledge/SearchLinesSparkle.tsx @@ -0,0 +1,20 @@ +// GENERATE BY script +// DON NOT EDIT IT MANUALLY + +import type { IconData } from '@/app/components/base/icons/IconBase' +import * as React from 'react' +import IconBase from '@/app/components/base/icons/IconBase' +import data from './SearchLinesSparkle.json' + +const Icon = ( + { + ref, + ...props + }: React.SVGProps & { + ref?: React.RefObject> + }, +) => + +Icon.displayName = 'SearchLinesSparkle' + +export default Icon diff --git a/web/app/components/base/icons/src/vender/knowledge/index.ts b/web/app/components/base/icons/src/vender/knowledge/index.ts index 7239511af3..44055c4975 100644 --- a/web/app/components/base/icons/src/vender/knowledge/index.ts +++ b/web/app/components/base/icons/src/vender/knowledge/index.ts @@ -11,5 +11,6 @@ export { default as HighQuality } from './HighQuality' export { default as HybridSearch } from './HybridSearch' export { default as ParentChildChunk } from './ParentChildChunk' export { default as QuestionAndAnswer } from './QuestionAndAnswer' +export { default as SearchLinesSparkle } from './SearchLinesSparkle' export { default as SearchMenu } from './SearchMenu' export { default as VectorSearch } from './VectorSearch' diff --git a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx index 5140c902f5..175b31154e 100644 --- a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx +++ b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx @@ -1,7 +1,7 @@ 'use client' import type { FC } from 'react' -import type { PreProcessingRule } from '@/models/datasets' +import type { PreProcessingRule, SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets' import { RiAlertFill, RiSearchEyeLine, @@ -12,6 +12,7 @@ import Button from '@/app/components/base/button' import Checkbox from '@/app/components/base/checkbox' import Divider from '@/app/components/base/divider' import Tooltip from '@/app/components/base/tooltip' +import SummaryIndexSetting from '@/app/components/datasets/settings/summary-index-setting' import { IS_CE_EDITION } from '@/config' import { ChunkingMode } from '@/models/datasets' import SettingCog from '../../assets/setting-gear-mod.svg' @@ -52,6 +53,8 @@ type GeneralChunkingOptionsProps = { onReset: () => void // Locale locale: string + summaryIndexSetting?: SummaryIndexSettingType + onSummaryIndexSettingChange?: (payload: SummaryIndexSettingType) => void } export const GeneralChunkingOptions: FC = ({ @@ -74,6 +77,8 @@ export const GeneralChunkingOptions: FC = ({ onPreview, onReset, locale, + summaryIndexSetting, + onSummaryIndexSettingChange, }) => { const { t } = useTranslation() @@ -146,6 +151,13 @@ export const GeneralChunkingOptions: FC = ({ ))} +
+ +
{IS_CE_EDITION && ( <> diff --git a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx index e46aa5817b..9a3fabfd71 100644 --- a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx +++ b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx @@ -2,7 +2,7 @@ import type { FC } from 'react' import type { ParentChildConfig } from '../hooks' -import type { ParentMode, PreProcessingRule } from '@/models/datasets' +import type { ParentMode, PreProcessingRule, SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets' import { RiSearchEyeLine } from '@remixicon/react' import Image from 'next/image' import { useTranslation } from 'react-i18next' @@ -11,6 +11,7 @@ import Checkbox from '@/app/components/base/checkbox' import Divider from '@/app/components/base/divider' import { ParentChildChunk } from '@/app/components/base/icons/src/vender/knowledge' import RadioCard from '@/app/components/base/radio-card' +import SummaryIndexSetting from '@/app/components/datasets/settings/summary-index-setting' import { ChunkingMode } from '@/models/datasets' import FileList from '../../assets/file-list-3-fill.svg' import Note from '../../assets/note-mod.svg' @@ -31,6 +32,8 @@ type ParentChildOptionsProps = { // State parentChildConfig: ParentChildConfig rules: PreProcessingRule[] + summaryIndexSetting?: SummaryIndexSettingType + onSummaryIndexSettingChange?: (payload: SummaryIndexSettingType) => void currentDocForm: ChunkingMode // Flags isActive: boolean @@ -51,6 +54,7 @@ type ParentChildOptionsProps = { export const ParentChildOptions: FC = ({ parentChildConfig, rules, + summaryIndexSetting, currentDocForm: _currentDocForm, isActive, isInUpload, @@ -62,6 +66,7 @@ export const ParentChildOptions: FC = ({ onChildDelimiterChange, onChildMaxLengthChange, onRuleToggle, + onSummaryIndexSettingChange, onPreview, onReset, }) => { @@ -183,6 +188,13 @@ export const ParentChildOptions: FC = ({ ))} +
+ +
diff --git a/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts b/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts index fd132b38ef..eaa51e393a 100644 --- a/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts +++ b/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts @@ -9,6 +9,7 @@ import type { CustomFile, FullDocumentDetail, ProcessRule, + SummaryIndexSetting as SummaryIndexSettingType, } from '@/models/datasets' import type { RetrievalConfig, RETRIEVE_METHOD } from '@/types/app' import { useCallback } from 'react' @@ -141,6 +142,7 @@ export const useDocumentCreation = (options: UseDocumentCreationOptions) => { retrievalConfig: RetrievalConfig, embeddingModel: DefaultModel, indexingTechnique: string, + summaryIndexSetting?: SummaryIndexSettingType, ): CreateDocumentReq | null => { if (isSetting) { return { @@ -148,6 +150,7 @@ export const useDocumentCreation = (options: UseDocumentCreationOptions) => { doc_form: currentDocForm, doc_language: docLanguage, process_rule: processRule, + summary_index_setting: summaryIndexSetting, retrieval_model: retrievalConfig, embedding_model: embeddingModel.model, embedding_model_provider: embeddingModel.provider, @@ -164,6 +167,7 @@ export const useDocumentCreation = (options: UseDocumentCreationOptions) => { }, indexing_technique: indexingTechnique, process_rule: processRule, + summary_index_setting: summaryIndexSetting, doc_form: currentDocForm, doc_language: docLanguage, retrieval_model: retrievalConfig, diff --git a/web/app/components/datasets/create/step-two/hooks/use-indexing-config.ts b/web/app/components/datasets/create/step-two/hooks/use-indexing-config.ts index 97fc9c260f..74924de6dc 100644 --- a/web/app/components/datasets/create/step-two/hooks/use-indexing-config.ts +++ b/web/app/components/datasets/create/step-two/hooks/use-indexing-config.ts @@ -1,4 +1,5 @@ import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations' +import type { SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets' import type { RetrievalConfig } from '@/types/app' import { useEffect, useMemo, useState } from 'react' import { checkShowMultiModalTip } from '@/app/components/datasets/settings/utils' @@ -29,6 +30,7 @@ export type UseIndexingConfigOptions = { initialRetrievalConfig?: RetrievalConfig isAPIKeySet: boolean hasSetIndexType: boolean + initialSummaryIndexSetting?: SummaryIndexSettingType } export const useIndexingConfig = (options: UseIndexingConfigOptions) => { @@ -38,6 +40,7 @@ export const useIndexingConfig = (options: UseIndexingConfigOptions) => { initialRetrievalConfig, isAPIKeySet, hasSetIndexType, + initialSummaryIndexSetting, } = options // Rerank model @@ -115,6 +118,11 @@ export const useIndexingConfig = (options: UseIndexingConfigOptions) => { // Get effective indexing technique const getIndexingTechnique = () => initialIndexType || indexType + // Summary index setting + const [summaryIndexSetting, setSummaryIndexSetting] = useState( + initialSummaryIndexSetting ?? undefined, + ) + return { // Index type indexType, @@ -137,6 +145,10 @@ export const useIndexingConfig = (options: UseIndexingConfigOptions) => { // Computed showMultiModalTip, + + // Summary index setting + summaryIndexSetting, + setSummaryIndexSetting, } } diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index b4d2c5f6e9..8302c1afbe 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -72,6 +72,7 @@ const StepTwo: FC = ({ initialRetrievalConfig: currentDataset?.retrieval_model_dict, isAPIKeySet, hasSetIndexType, + initialSummaryIndexSetting: currentDataset?.summary_index_setting, }) const preview = usePreviewState({ dataSourceType, files, notionPages, websitePages, documentDetail, datasetId }) const creation = useDocumentCreation({ @@ -156,7 +157,7 @@ const StepTwo: FC = ({ }) if (!isValid) return - const params = creation.buildCreationParams(currentDocForm, docLanguage, segmentation.getProcessRule(currentDocForm), indexing.retrievalConfig, indexing.embeddingModel, indexing.getIndexingTechnique()) + const params = creation.buildCreationParams(currentDocForm, docLanguage, segmentation.getProcessRule(currentDocForm), indexing.retrievalConfig, indexing.embeddingModel, indexing.getIndexingTechnique(), indexing.summaryIndexSetting) if (!params) return await creation.executeCreation(params, indexing.indexType, indexing.retrievalConfig) @@ -217,6 +218,8 @@ const StepTwo: FC = ({ onPreview={updatePreview} onReset={segmentation.resetToDefaults} locale={locale} + summaryIndexSetting={indexing.summaryIndexSetting} + onSummaryIndexSettingChange={indexing.setSummaryIndexSetting} /> )} {showParentChildOption && ( @@ -236,6 +239,8 @@ const StepTwo: FC = ({ onRuleToggle={segmentation.toggleRule} onPreview={updatePreview} onReset={segmentation.resetToDefaults} + summaryIndexSetting={indexing.summaryIndexSetting} + onSummaryIndexSettingChange={indexing.setSummaryIndexSetting} /> )} diff --git a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx index db36ca471a..27c7f49cbc 100644 --- a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx +++ b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import Confirm from '@/app/components/base/confirm' import Divider from '@/app/components/base/divider' +import { SearchLinesSparkle } from '@/app/components/base/icons/src/vender/knowledge' import { cn } from '@/utils/classnames' const i18nPrefix = 'batchAction' @@ -15,6 +16,7 @@ type IBatchActionProps = { onBatchEnable: () => void onBatchDisable: () => void onBatchDelete: () => Promise + onBatchSummary?: () => void onArchive?: () => void onEditMetadata?: () => void onBatchReIndex?: () => void @@ -26,6 +28,7 @@ const BatchAction: FC = ({ selectedIds, onBatchEnable, onBatchDisable, + onBatchSummary, onArchive, onBatchDelete, onEditMetadata, @@ -82,7 +85,16 @@ const BatchAction: FC = ({ {t('metadata.metadata', { ns: 'dataset' })} )} - + {onBatchSummary && ( + + )} {onArchive && (