diff --git a/web/app/components/datasets/hit-testing/assets/test-data.ts b/web/app/components/datasets/hit-testing/assets/test-data.ts index 623f7e587c..035bfcc827 100644 --- a/web/app/components/datasets/hit-testing/assets/test-data.ts +++ b/web/app/components/datasets/hit-testing/assets/test-data.ts @@ -48,6 +48,11 @@ export const generalResultData: HitTesting[] = [ score: 0.8771945, content: 'It is quite natural for academics who are continuously told to “publish or perish” to want to always create something from scratch that is their own fresh creation.', }, + { + id: '2', + score: 0.5, + content: 'It is quite natural for ', + }, ], score: 0.8771945, tsne_position: null, diff --git a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx b/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx index b685689b2e..f6be610114 100644 --- a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx +++ b/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx @@ -1,9 +1,8 @@ 'use client' import type { FC } from 'react' import React from 'react' -import { useTranslation } from 'react-i18next' -import { SliceContent, SliceLabel } from '../../formatted-text/flavours/shared' -import cn from '@/utils/classnames' +import { SliceContent } from '../../formatted-text/flavours/shared' +import Score from './score' import type { HitTestingChildChunk } from '@/models/datasets' type Props = { @@ -15,16 +14,16 @@ const ChildChunks: FC = ({ payload, isShowAll, }) => { - const { t } = useTranslation() const { id, score, content } = payload return ( -
- - {id} {score} - - - {content} - +
+
+
C-{id}
+ +
+ {content}
) } diff --git a/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx b/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx index 51c6ec0343..18e89f5890 100644 --- a/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx +++ b/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx @@ -13,6 +13,8 @@ import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader import cn from '@/utils/classnames' import Tag from '@/app/components/datasets/documents/detail/completed/common/tag' +const i18nPrefix = 'datasetHitTesting' + type Props = { payload: HitTesting onHide: () => void @@ -24,19 +26,19 @@ const ChunkDetailModal: FC = ({ }) => { const { t } = useTranslation() const { segment, score, child_chunks } = payload - const { position, word_count, content, keywords, document } = segment + const { position, content, keywords, document } = segment const isParentChildRetrieval = !!(child_chunks && child_chunks.length > 0) const extension = document.name.split('.').slice(0, -1)[0] as FileAppearanceTypeEnum - + const maxHeighClassName = 'max-h-[752px] overflow-y-auto' return ( -
+
{/* Meta info */}
@@ -54,12 +56,12 @@ const ChunkDetailModal: FC = ({
-
+
{content}
{!isParentChildRetrieval && keywords && keywords.length > 0 && ( -
-
{t('dataset.keywords')}
+
+
{t(`${i18nPrefix}.keyword`)}
{keywords.map(keyword => ( @@ -71,8 +73,8 @@ const ChunkDetailModal: FC = ({ {isParentChildRetrieval && (
-
{t('dataset.hitChunks', { num: child_chunks.length })}
-
+
{t(`${i18nPrefix}.hitChunks`, { num: child_chunks.length })}
+
{child_chunks.map(item => ( ))} diff --git a/web/app/components/datasets/hit-testing/components/result-item.tsx b/web/app/components/datasets/hit-testing/components/result-item.tsx index e1e51bfbe9..e8f85baf9f 100644 --- a/web/app/components/datasets/hit-testing/components/result-item.tsx +++ b/web/app/components/datasets/hit-testing/components/result-item.tsx @@ -15,6 +15,7 @@ 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' +const i18nPrefix = 'datasetHitTesting' type Props = { payload: HitTesting } @@ -54,17 +55,21 @@ const ResultItem: FC = ({
{/* Main */} -
-
{content}
+
+
{content}
{isParentChildRetrieval && ( -
+
-
{t('dataset.hitChunks', { num: child_chunks.length })}
+
{t(`${i18nPrefix}.dataset.hitChunks`, { num: child_chunks.length })}
+
+
+ {child_chunks.map(item => ( +
+ +
+ ))}
- {child_chunks.map(item => ( - - ))}
)} {!isParentChildRetrieval && keywords && keywords.length > 0 && ( @@ -76,7 +81,7 @@ const ResultItem: FC = ({ )}
{/* Foot */} -
+
{document.name} @@ -85,7 +90,7 @@ const ResultItem: FC = ({ className='flex items-center space-x-1 cursor-pointer text-text-tertiary' onClick={showDetailModal} > -
{t('dataset.open')}
+
{t(`${i18nPrefix}.open`)}
diff --git a/web/app/components/datasets/hit-testing/components/score.tsx b/web/app/components/datasets/hit-testing/components/score.tsx index 650ecd497f..bcbcabf20e 100644 --- a/web/app/components/datasets/hit-testing/components/score.tsx +++ b/web/app/components/datasets/hit-testing/components/score.tsx @@ -1,18 +1,21 @@ 'use client' import type { FC } from 'react' import React from 'react' +import cn from '@/utils/classnames' type Props = { value: number + besideChunkName?: boolean } const Score: FC = ({ value, + besideChunkName, }) => { return ( -
+
-
+
score
{value.toFixed(2)}
diff --git a/web/i18n/en-US/dataset-hit-testing.ts b/web/i18n/en-US/dataset-hit-testing.ts index 385d68c771..8b8629e90a 100644 --- a/web/i18n/en-US/dataset-hit-testing.ts +++ b/web/i18n/en-US/dataset-hit-testing.ts @@ -25,6 +25,10 @@ const translation = { noRecentTip: 'No recent query results here', viewChart: 'View VECTOR CHART', viewDetail: 'View Detail', + chunkDetail: 'Chunk Detail', + hitChunks: 'Hit {{num}} child chunks', + open: 'Open', + keyword: 'Keywords', } export default translation diff --git a/web/i18n/zh-Hans/dataset-hit-testing.ts b/web/i18n/zh-Hans/dataset-hit-testing.ts index 6aba135c71..caf88acc76 100644 --- a/web/i18n/zh-Hans/dataset-hit-testing.ts +++ b/web/i18n/zh-Hans/dataset-hit-testing.ts @@ -25,6 +25,10 @@ const translation = { noRecentTip: '最近无查询结果', viewChart: '查看向量图表', viewDetail: '查看详情', + chunkDetail: '段落详情', + hitChunks: '命中 {{num}} 个子段落', + open: '打开', + keyword: '关键词', } export default translation