From f894fb05c1ddf2dacd83f688c972d935d072ed60 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Tue, 10 Dec 2024 16:04:42 +0800 Subject: [PATCH 1/5] fix: retrive config cannot enable rerank --- .../datasets/common/retrieval-method-config/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app/components/datasets/common/retrieval-method-config/index.tsx b/web/app/components/datasets/common/retrieval-method-config/index.tsx index 6509ed995c..0244a13655 100644 --- a/web/app/components/datasets/common/retrieval-method-config/index.tsx +++ b/web/app/components/datasets/common/retrieval-method-config/index.tsx @@ -64,7 +64,7 @@ const RetrievalMethodConfig: FC = ({ isActive={ value.search_method === RETRIEVE_METHOD.semantic } - onClick={() => onChange({ + onSwitched={() => onChange({ ...value, search_method: RETRIEVE_METHOD.semantic, })} @@ -85,7 +85,7 @@ const RetrievalMethodConfig: FC = ({ isActive={ value.search_method === RETRIEVE_METHOD.fullText } - onClick={() => onChange({ + onSwitched={() => onChange({ ...value, search_method: RETRIEVE_METHOD.fullText, })} From 77185d961786e5fb53bc8a679091ac2b8045a1be Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 10 Dec 2024 15:06:56 +0800 Subject: [PATCH 2/5] feat: dataset info to new ui --- .../components/app-sidebar/dataset-info.tsx | 42 +++++++++++++++++++ web/app/components/app-sidebar/index.tsx | 18 ++++++-- web/i18n/en-US/dataset.ts | 1 + web/i18n/zh-Hans/dataset.ts | 5 ++- 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 web/app/components/app-sidebar/dataset-info.tsx diff --git a/web/app/components/app-sidebar/dataset-info.tsx b/web/app/components/app-sidebar/dataset-info.tsx new file mode 100644 index 0000000000..b5c2f0c235 --- /dev/null +++ b/web/app/components/app-sidebar/dataset-info.tsx @@ -0,0 +1,42 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import { useTranslation } from 'react-i18next' +import AppIcon from '../base/app-icon' + +const DatasetSvg = + + + +type Props = { + isExternal?: boolean + name: string + description: string + expand: boolean +} + +const DatasetInfo: FC = ({ + name, + description, + isExternal, + expand, +}) => { + const { t } = useTranslation() + return ( +
+
+ +
+ {expand && ( +
+
+ {name} +
+
{isExternal ? t('dataset.externalTag') : t('dataset.localDocs')}
+
{description}
+
+ )} +
+ ) +} +export default React.memo(DatasetInfo) diff --git a/web/app/components/app-sidebar/index.tsx b/web/app/components/app-sidebar/index.tsx index 5ee063ad64..1ba8aeecc9 100644 --- a/web/app/components/app-sidebar/index.tsx +++ b/web/app/components/app-sidebar/index.tsx @@ -4,12 +4,14 @@ import NavLink from './navLink' import type { NavIcon } from './navLink' import AppBasic from './basic' import AppInfo from './app-info' +import DatasetInfo from './dataset-info' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { AlignLeft01, AlignRight01, } from '@/app/components/base/icons/src/vender/line/layout' import { useStore as useAppStore } from '@/app/components/app/store' +import cn from '@/utils/classnames' export type IAppDetailNavProps = { iconType?: 'app' | 'dataset' | 'notion' @@ -63,7 +65,15 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati {iconType === 'app' && ( )} - {iconType !== 'app' && ( + {iconType === 'dataset' && ( + + )} + {!['app', 'dataset'].includes(iconType) && ( )} - {!expand && ( -
- )} +
+
+
{ !isMobile && ( diff --git a/web/app/components/base/linked-apps-panel/index.tsx b/web/app/components/base/linked-apps-panel/index.tsx new file mode 100644 index 0000000000..4320cb0fc6 --- /dev/null +++ b/web/app/components/base/linked-apps-panel/index.tsx @@ -0,0 +1,62 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import Link from 'next/link' +import { useTranslation } from 'react-i18next' +import { RiArrowRightUpLine } from '@remixicon/react' +import cn from '@/utils/classnames' +import AppIcon from '@/app/components/base/app-icon' +import type { RelatedApp } from '@/models/datasets' + +type ILikedItemProps = { + appStatus?: boolean + detail: RelatedApp + isMobile: boolean +} + +const appTypeMap = { + 'chat': 'Chatbot', + 'completion': 'Completion', + 'agent-chat': 'Agent', + 'advanced-chat': 'Chatflow', + 'workflow': 'Workflow', +} + +const LikedItem = ({ + detail, + isMobile, +}: ILikedItemProps) => { + return ( + +
+
+ +
+ {!isMobile &&
{detail?.name || '--'}
} +
+
{appTypeMap[detail.mode]}
+ + + ) +} + +type Props = { + relatedApps: RelatedApp[] + isMobile: boolean +} + +const LinkedAppsPanel: FC = ({ + relatedApps, + isMobile, +}) => { + const { t } = useTranslation() + return ( +
+
{relatedApps.length || '--'} {t('common.datasetMenus.relatedApp')}
+ {relatedApps.map((item, index) => ( + + ))} +
+ ) +} +export default React.memo(LinkedAppsPanel) diff --git a/web/app/components/base/tooltip/index.tsx b/web/app/components/base/tooltip/index.tsx index e5f27fdd8c..de0a9aacfa 100644 --- a/web/app/components/base/tooltip/index.tsx +++ b/web/app/components/base/tooltip/index.tsx @@ -14,6 +14,7 @@ export type TooltipProps = { popupContent?: React.ReactNode children?: React.ReactNode popupClassName?: string + noDecoration?: boolean offset?: OffsetOptions needsDelay?: boolean asChild?: boolean @@ -27,6 +28,7 @@ const Tooltip: FC = ({ popupContent, children, popupClassName, + noDecoration, offset, asChild = true, needsDelay = false, @@ -96,7 +98,7 @@ const Tooltip: FC = ({ > {popupContent && (
triggerMethod === 'hover' && setHoverPopup()} From 87e284ef75e117d7190285219ffa09766dc2528f Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 10 Dec 2024 17:19:05 +0800 Subject: [PATCH 4/5] feat: no linked app ui --- .../[datasetId]/layout.tsx | 73 ++++++++----------- web/i18n/en-US/common.ts | 3 +- web/i18n/zh-Hans/common.ts | 3 +- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx index 0637dac1ea..1b327185e5 100644 --- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx +++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx @@ -7,27 +7,21 @@ import { useTranslation } from 'react-i18next' import { useBoolean } from 'ahooks' import { Cog8ToothIcon, - // CommandLineIcon, - Squares2X2Icon, - // eslint-disable-next-line sort-imports - PuzzlePieceIcon, DocumentTextIcon, PaperClipIcon, - QuestionMarkCircleIcon, } from '@heroicons/react/24/outline' import { Cog8ToothIcon as Cog8ToothSolidIcon, // CommandLineIcon as CommandLineSolidIcon, DocumentTextIcon as DocumentTextSolidIcon, } from '@heroicons/react/24/solid' -import { RiInformation2Line } from '@remixicon/react' +import { RiApps2AddLine, RiInformation2Line } from '@remixicon/react' import s from './style.module.css' import classNames from '@/utils/classnames' import { fetchDatasetDetail, fetchDatasetRelatedApps } from '@/service/datasets' import type { RelatedAppResponse } from '@/models/datasets' import AppSideBar from '@/app/components/app-sidebar' import Loading from '@/app/components/base/loading' -import FloatPopoverContainer from '@/app/components/base/float-popover-container' import DatasetDetailContext from '@/context/dataset-detail' import { DataSourceType } from '@/models/datasets' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' @@ -74,9 +68,10 @@ const BookOpenIcon = ({ className }: SVGProps) => { type IExtraInfoProps = { isMobile: boolean relatedApps?: RelatedAppResponse + expand: boolean } -const ExtraInfo = ({ isMobile, relatedApps }: IExtraInfoProps) => { +const ExtraInfo = ({ isMobile, relatedApps, expand }: IExtraInfoProps) => { const locale = getLocaleOnClient() const [isShowTips, { toggle: toggleTips, set: setShowTips }] = useBoolean(!isMobile) const { t } = useTranslation() @@ -114,45 +109,39 @@ const ExtraInfo = ({ isMobile, relatedApps }: IExtraInfoProps) => { {relatedAppsTotal || '--'}
} - )} - {!hasRelatedApps && ( - - + {!hasRelatedApps && !expand && ( + +
+ +
+
{t('common.datasetMenus.emptyTip')}
+ + + {t('common.datasetMenus.viewDoc')} +
} > -
-
-
- -
-
- -
-
-
{t('common.datasetMenus.emptyTip')}
- - - {t('common.datasetMenus.viewDoc')} - +
+ {t('common.datasetMenus.noRelatedApp')} +
- + )}
} @@ -223,7 +212,7 @@ const DatasetDetailLayout: FC = (props) => { desc={datasetRes?.description || '--'} isExternal={datasetRes?.provider === 'external'} navigation={navigation} - extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => : undefined} + extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => : undefined} iconType={datasetRes?.data_source_type === DataSourceType.NOTION ? 'notion' : 'dataset'} />} Date: Tue, 10 Dec 2024 17:32:31 +0800 Subject: [PATCH 5/5] fix: dataset settings --- .../common/retrieval-method-config/index.tsx | 2 +- .../datasets/settings/form/index.tsx | 3 +- .../settings/index-method-radio/index.tsx | 54 +++++++++++-------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/web/app/components/datasets/common/retrieval-method-config/index.tsx b/web/app/components/datasets/common/retrieval-method-config/index.tsx index 0244a13655..986135e3c6 100644 --- a/web/app/components/datasets/common/retrieval-method-config/index.tsx +++ b/web/app/components/datasets/common/retrieval-method-config/index.tsx @@ -104,7 +104,7 @@ const RetrievalMethodConfig: FC = ({ title={
{t('dataset.retrieval.hybrid_search.title')}
- +
} description={t('dataset.retrieval.hybrid_search.description')} isActive={ diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsx index 7ce31986c1..22b52bb8f2 100644 --- a/web/app/components/datasets/settings/form/index.tsx +++ b/web/app/components/datasets/settings/form/index.tsx @@ -17,7 +17,7 @@ import Textarea from '@/app/components/base/textarea' import Divider from '@/app/components/base/divider' import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development' import { updateDatasetSetting } from '@/service/datasets' -import type { DataSetListResponse } from '@/models/datasets' +import { type DataSetListResponse } from '@/models/datasets' import DatasetDetailContext from '@/context/dataset-detail' import { type RetrievalConfig } from '@/types/app' import { useAppContext } from '@/context/app-context' @@ -234,6 +234,7 @@ const Form = () => { disable={!currentDataset?.embedding_available} value={indexMethod} onChange={v => setIndexMethod(v)} + docForm={currentDataset.doc_form} />
diff --git a/web/app/components/datasets/settings/index-method-radio/index.tsx b/web/app/components/datasets/settings/index-method-radio/index.tsx index 2bf6f36ce1..e563b96256 100644 --- a/web/app/components/datasets/settings/index-method-radio/index.tsx +++ b/web/app/components/datasets/settings/index-method-radio/index.tsx @@ -1,8 +1,10 @@ 'use client' import { useTranslation } from 'react-i18next' +import { IndexingType } from '../../create/step-two' import s from './index.module.css' import classNames from '@/utils/classnames' import type { DataSet } from '@/models/datasets' +import { ChuckingMode } from '@/models/datasets' const itemClass = ` w-full sm:w-[234px] p-3 rounded-xl bg-gray-25 border border-gray-100 cursor-pointer @@ -15,6 +17,7 @@ type IIndexMethodRadioProps = { onChange: (v?: DataSet['indexing_technique']) => void disable?: boolean itemClassName?: string + docForm?: ChuckingMode } const IndexMethodRadio = ({ @@ -22,6 +25,7 @@ const IndexMethodRadio = ({ onChange, disable, itemClassName, + docForm, }: IIndexMethodRadioProps) => { const { t } = useTranslation() const options = [ @@ -42,29 +46,35 @@ const IndexMethodRadio = ({ return (
{ - options.map(option => ( -
{ - if (!disable) - onChange(option.key as DataSet['indexing_technique']) - }} - > -
-
-
{option.text}
-
+ options.map((option) => { + const isParentChild = docForm === ChuckingMode.parentChild + return ( +
{ + if (isParentChild && option.key === IndexingType.ECONOMICAL) + return + if (!disable) + onChange(option.key as DataSet['indexing_technique']) + }} + > +
+
+
{option.text}
+
+
+
{option.desc}
-
{option.desc}
-
- )) + ) + }) }
)