From 8b650fc9eff295704c993c0fe91c3a4b9afb4520 Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 2 Dec 2024 19:00:11 +0800 Subject: [PATCH] Feat: Supports page rank score for different knowledge bases. #3794 (#3800) ### What problem does this PR solve? Feat: Supports page rank score for different knowledge bases. #3794 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/editable-cell.tsx | 6 ++-- web/src/components/page-rank.tsx | 33 +++++++++++++++++++ web/src/locales/en.ts | 3 ++ web/src/locales/zh-traditional.ts | 3 ++ web/src/locales/zh.ts | 3 ++ .../knowledge-setting/configuration.tsx | 3 +- 6 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 web/src/components/page-rank.tsx diff --git a/web/src/components/editable-cell.tsx b/web/src/components/editable-cell.tsx index 4a960d4711c..ff5092ef3f5 100644 --- a/web/src/components/editable-cell.tsx +++ b/web/src/components/editable-cell.tsx @@ -2,7 +2,7 @@ import { Form, FormInstance, Input, InputRef, Typography } from 'antd'; import React, { useContext, useEffect, useRef, useState } from 'react'; const EditableContext = React.createContext | null>(null); -const { Paragraph, Text } = Typography; +const { Text } = Typography; interface EditableRowProps { index: number; @@ -95,9 +95,7 @@ export const EditableCell: React.FC = ({ // style={{ paddingRight: 24 }} onClick={toggleEdit} > - - {children} - + {children} ); } diff --git a/web/src/components/page-rank.tsx b/web/src/components/page-rank.tsx new file mode 100644 index 00000000000..8d72e5bdb08 --- /dev/null +++ b/web/src/components/page-rank.tsx @@ -0,0 +1,33 @@ +import { useTranslate } from '@/hooks/common-hooks'; +import { Flex, Form, InputNumber, Slider } from 'antd'; + +const PageRank = () => { + const { t } = useTranslate('knowledgeConfiguration'); + + return ( + + + + + + + + + + + + + ); +}; + +export default PageRank; diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 0c5d54755e4..22c86ee9ce9 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -303,6 +303,9 @@ The above is the content you need to summarize.`, randomSeed: 'Random seed', randomSeedMessage: 'Random seed is required', entityTypes: 'Entity types', + pageRank: 'Page rank', + pageRankTip: `This is used to boost the relevance score. The relevance score with all the retrieved chunks will plus this number. +When you want to search the given knowledge base at first place, set a higher pagerank score than others.`, }, chunk: { chunk: 'Chunk', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 3a35402daf9..c3cc5e1c69a 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -287,6 +287,9 @@ export default { thresholdTip: '閾值越大,聚類越少。', maxClusterTip: '最大聚類數。', entityTypes: '實體類型', + pageRank: '頁面排名', + pageRankTip: `這用來提高相關性分數。所有檢索到的區塊的相關性得分將加上該數字。 +當您想要先搜尋給定的知識庫時,請設定比其他人更高的 pagerank 分數。`, }, chunk: { chunk: '解析塊', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 96ea9b82c9a..8cb523dd5da 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -304,6 +304,9 @@ export default { thresholdTip: '阈值越大,聚类越少。', maxClusterTip: '最大聚类数。', entityTypes: '实体类型', + pageRank: '页面排名', + pageRankTip: `这用于提高相关性得分。所有检索到的块的相关性得分将加上此数字。 +当您想首先搜索给定的知识库时,请设置比其他知识库更高的 pagerank 得分。`, }, chunk: { chunk: '解析块', diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx index 8800b718420..564ce6e187d 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx @@ -8,6 +8,7 @@ import EntityTypesItem from '@/components/entity-types-item'; import ExcelToHtml from '@/components/excel-to-html'; import LayoutRecognize from '@/components/layout-recognize'; import MaxTokenNumber from '@/components/max-token-number'; +import PageRank from '@/components/page-rank'; import ParseConfiguration, { showRaptorParseConfiguration, } from '@/components/parse-configuration'; @@ -112,7 +113,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => { ))} - + {({ getFieldValue }) => { const parserId = getFieldValue('parser_id');