From 1dca5edcc6efa23cb6666e97b6278134bc7f906d Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Tue, 24 Oct 2023 17:32:36 +0800 Subject: [PATCH] v4.5.1-3 (#427) --- README.md | 6 +- .../content/docs/installation/upgrading/45.md | 1 - .../docs/workflow/examples/lab_appointment.md | 2 +- .../docs/workflow/examples/op_question.md | 2 +- projects/app/data/config.json | 2 +- projects/app/public/locales/en/common.json | 8 +- projects/app/public/locales/zh/common.json | 8 +- .../app/src/components/ChatBox/QuoteModal.tsx | 119 +++++++++++------- .../components/Icon/icons/common/text/t.svg | 8 ++ .../Icon/icons/light/rightArrow.svg | 9 +- projects/app/src/components/Icon/index.tsx | 3 +- .../src/pages/api/core/dataset/searchTest.ts | 2 +- .../AdEdit/components/modules/NodeCard.tsx | 10 +- .../AdEdit/components/render/RenderInput.tsx | 11 +- .../app/detail/components/BasicEdit/index.tsx | 1 - .../pages/dataset/detail/components/Test.tsx | 19 +-- .../src/service/moduleDispatch/kb/search.ts | 2 +- projects/app/src/service/pg.ts | 2 +- 18 files changed, 142 insertions(+), 73 deletions(-) create mode 100644 projects/app/src/components/Icon/icons/common/text/t.svg diff --git a/README.md b/README.md index 9869b215b..43ab169d0 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b ## 🛸 在线使用 -+ 🌐 国内版:[ai.fastgpt.in](https://ai.fastgpt.in/) -+ 🌍 海外版:[fastgpt.run](https://fastgpt.run/) +- 🌐 国内版:[ai.fastgpt.in](https://ai.fastgpt.in/) +- 🌍 海外版:[fastgpt.run](https://fastgpt.run/) | | | | ---------------------------------- | ---------------------------------- | @@ -128,7 +128,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b 本仓库遵循 [FastGPT Open Source License](./LICENSE) 开源协议。 -1. 允许作为后台服务直接商用,但不允许直接使用 SaaS 服务商用。 +1. 允许作为后台服务直接商用,但不允许提供 SaaS 服务。 2. 需保留相关版权信息。 3. 完整请查看 [FastGPT Open Source License](./LICENSE) 4. 联系方式:yujinlong@sealos.io, [点击查看定价策略](https://doc.fastgpt.run/docs/commercial) diff --git a/docSite/content/docs/installation/upgrading/45.md b/docSite/content/docs/installation/upgrading/45.md index e85f2f5f2..21f1c7f3c 100644 --- a/docSite/content/docs/installation/upgrading/45.md +++ b/docSite/content/docs/installation/upgrading/45.md @@ -31,7 +31,6 @@ select pg_reload_conf(); -- 重构数据库索引和排序 REINDEX DATABASE postgres; -ALTER DATABASE postgres REFRESH COLLATION VERSION; -- 开始构建索引,该索引构建时间非常久,直接点击右上角的叉,退出 Terminal 即可 CREATE INDEX CONCURRENTLY vector_index ON modeldata USING hnsw (vector vector_ip_ops) WITH (m = 16, ef_construction = 64); diff --git a/docSite/content/docs/workflow/examples/lab_appointment.md b/docSite/content/docs/workflow/examples/lab_appointment.md index 7e5b7fb4f..46afdea9b 100644 --- a/docSite/content/docs/workflow/examples/lab_appointment.md +++ b/docSite/content/docs/workflow/examples/lab_appointment.md @@ -527,7 +527,7 @@ HTTP 模块允许你调用任意 POST 类型的 HTTP 接口,从而实验一些 { "moduleId": "zltb5l", "name": "知识库搜索", - "flowType": "kbSearchNode", + "flowType": "datasetSearchNode", "showStatus": true, "position": { "x": 1634.995464753433, diff --git a/docSite/content/docs/workflow/examples/op_question.md b/docSite/content/docs/workflow/examples/op_question.md index 7920b6000..fa070b2f1 100644 --- a/docSite/content/docs/workflow/examples/op_question.md +++ b/docSite/content/docs/workflow/examples/op_question.md @@ -97,7 +97,7 @@ weight: 144 { "moduleId": "nkxlso", "name": "知识库搜索", - "flowType": "kbSearchNode", + "flowType": "datasetSearchNode", "showStatus": true, "position": { "x": 1542.6434554710224, diff --git a/projects/app/data/config.json b/projects/app/data/config.json index 41d8e63f0..97837f48f 100644 --- a/projects/app/data/config.json +++ b/projects/app/data/config.json @@ -2,7 +2,7 @@ "SystemParams": { "vectorMaxProcess": 15, "qaMaxProcess": 15, - "pgHNSWEfSearch ": 60 + "pgHNSWEfSearch": 100 }, "ChatModels": [ { diff --git a/projects/app/public/locales/en/common.json b/projects/app/public/locales/en/common.json index 1e8a98767..1dad6b695 100644 --- a/projects/app/public/locales/en/common.json +++ b/projects/app/public/locales/en/common.json @@ -175,10 +175,16 @@ "dataset": { "Choose Dataset": "Chookse Dataset", "Dataset": "Dataset", + "Go Dataset": "To Dataset", + "Quote Length": "Quote Length", "Read Dataset": "Read Dataset", "Search Top K": "Top K", "Set Empty Result Tip": ",Response empty text", - "Similarity": "Similarity" + "Similarity": "Similarity", + "data": { + "Edit": "Edit Data", + "id": "Data ID" + } } }, "dataset": { diff --git a/projects/app/public/locales/zh/common.json b/projects/app/public/locales/zh/common.json index f3618c4b4..6b03a73cf 100644 --- a/projects/app/public/locales/zh/common.json +++ b/projects/app/public/locales/zh/common.json @@ -175,10 +175,16 @@ "dataset": { "Choose Dataset": "关联知识库", "Dataset": "知识库", + "Go Dataset": "前往知识库", + "Quote Length": "引用内容长度", "Read Dataset": "查看知识库详情", "Search Top K": "单次搜索数量", "Set Empty Result Tip": ",未搜索到内容时回复指定内容", - "Similarity": "相似度" + "Similarity": "相似度", + "data": { + "Edit": "编辑数据", + "id": "数据ID" + } } }, "dataset": { diff --git a/projects/app/src/components/ChatBox/QuoteModal.tsx b/projects/app/src/components/ChatBox/QuoteModal.tsx index 762869045..3132e88d1 100644 --- a/projects/app/src/components/ChatBox/QuoteModal.tsx +++ b/projects/app/src/components/ChatBox/QuoteModal.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useMemo, useState } from 'react'; -import { ModalBody, Box, useTheme, Flex, Progress } from '@chakra-ui/react'; +import { ModalBody, Box, useTheme, Flex, Progress, Link } from '@chakra-ui/react'; import { getDatasetDataItemById } from '@/web/core/dataset/api'; import { useLoading } from '@/web/common/hooks/useLoading'; import { useToast } from '@/web/common/hooks/useToast'; @@ -13,6 +13,9 @@ import MyModal from '../MyModal'; import { useTranslation } from 'react-i18next'; import { useRouter } from 'next/router'; import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type'; +import MyTooltip from '../MyTooltip'; +import NextLink from 'next/link'; +import { useSystemStore } from '@/web/common/system/useSystemStore'; const QuoteModal = ({ rawSearch = [], @@ -22,6 +25,7 @@ const QuoteModal = ({ onClose: () => void; }) => { const { t } = useTranslation(); + const { isPc } = useSystemStore(); const theme = useTheme(); const router = useRouter(); const { toast } = useToast(); @@ -67,7 +71,7 @@ const QuoteModal = ({ title={ <> 知识库引用({rawSearch.length}条) - + 注意: 修改知识库内容成功后,此处不会显示变更情况。点击编辑后,会显示知识库最新的内容。 @@ -89,58 +93,83 @@ const QuoteModal = ({ border={theme.borders.base} _notLast={{ mb: 2 }} position={'relative'} - _hover={{ '& .edit': { display: 'flex' } }} overflow={'hidden'} > {!isShare && ( - + - - {item.score && ( - <> - - {item.score.toFixed(4)} - - )} + + + {t('core.dataset.Go Dataset')} + + )} {item.q} {item.a} - {item.id && !isShare && ( - - onclickEdit(item)} - /> - + {!isShare && ( + + {isPc && ( + + + # {item.id} + + + )} + + + + {item.q.length + item.a.length} + + + {!isShare && item.score && ( + + + + + {item.score.toFixed(4)} + + + )} + + {item.id && ( + + + onclickEdit(item)} + /> + + + )} + )} ))} diff --git a/projects/app/src/components/Icon/icons/common/text/t.svg b/projects/app/src/components/Icon/icons/common/text/t.svg new file mode 100644 index 000000000..123fa6004 --- /dev/null +++ b/projects/app/src/components/Icon/icons/common/text/t.svg @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/projects/app/src/components/Icon/icons/light/rightArrow.svg b/projects/app/src/components/Icon/icons/light/rightArrow.svg index 892a8149e..8d29a8ba1 100644 --- a/projects/app/src/components/Icon/icons/light/rightArrow.svg +++ b/projects/app/src/components/Icon/icons/light/rightArrow.svg @@ -1,3 +1,8 @@ - - + + + \ No newline at end of file diff --git a/projects/app/src/components/Icon/index.tsx b/projects/app/src/components/Icon/index.tsx index 674855f40..3d6a38a72 100644 --- a/projects/app/src/components/Icon/index.tsx +++ b/projects/app/src/components/Icon/index.tsx @@ -91,7 +91,8 @@ const iconPaths = { loading: () => import('./icons/light/loading.svg'), pause: () => import('./icons/common/pause.svg'), 'core/app/aiLight': () => import('./icons/core/app/aiLight.svg'), - 'core/app/aiFill': () => import('./icons/core/app/aiFill.svg') + 'core/app/aiFill': () => import('./icons/core/app/aiFill.svg'), + 'common/text/t': () => import('./icons/common/text/t.svg') }; export type IconName = keyof typeof iconPaths; diff --git a/projects/app/src/pages/api/core/dataset/searchTest.ts b/projects/app/src/pages/api/core/dataset/searchTest.ts index b27608ceb..4cc929ef6 100644 --- a/projects/app/src/pages/api/core/dataset/searchTest.ts +++ b/projects/app/src/pages/api/core/dataset/searchTest.ts @@ -41,7 +41,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex const results: any = await PgClient.query( `BEGIN; - SET LOCAL hnsw.ef_search = ${global.systemEnv.pgHNSWEfSearch || 60}; + SET LOCAL hnsw.ef_search = ${global.systemEnv.pgHNSWEfSearch || 100}; select id, q, a, dataset_id, collection_id, (vector <#> '[${ vectors[0] }]') * -1 AS score from ${PgDatasetTableName} where dataset_id='${datasetId}' AND user_id='${userId}' ORDER BY vector <#> '[${ diff --git a/projects/app/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx b/projects/app/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx index db1ff2296..777b5a4b4 100644 --- a/projects/app/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx +++ b/projects/app/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx @@ -22,7 +22,6 @@ const NodeCard = (props: Props) => { name = '未知模块', description, minW = '300px', - moduleId } = props; const { onCopyNode, onDelNode } = useFlowStore(); @@ -81,7 +80,14 @@ const NodeCard = (props: Props) => { ); return ( - + diff --git a/projects/app/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx b/projects/app/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx index c1300d5e0..efc76ed63 100644 --- a/projects/app/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx +++ b/projects/app/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx @@ -498,7 +498,7 @@ var SelectDatasetRender = React.memo(function SelectDatasetRender({ item, module return ( <> - + @@ -512,7 +512,14 @@ var SelectDatasetRender = React.memo(function SelectDatasetRender({ item, module borderRadius={'md'} > - + {item.name} diff --git a/projects/app/src/pages/app/detail/components/BasicEdit/index.tsx b/projects/app/src/pages/app/detail/components/BasicEdit/index.tsx index b83b9939e..da100383f 100644 --- a/projects/app/src/pages/app/detail/components/BasicEdit/index.tsx +++ b/projects/app/src/pages/app/detail/components/BasicEdit/index.tsx @@ -51,7 +51,6 @@ import { getGuideModule } from '@/global/core/app/modules/utils'; import dynamic from 'next/dynamic'; import MySelect from '@/components/Select'; -import MySlider from '@/components/Slider'; import MyTooltip from '@/components/MyTooltip'; import Avatar from '@/components/Avatar'; import MyIcon from '@/components/Icon'; diff --git a/projects/app/src/pages/dataset/detail/components/Test.tsx b/projects/app/src/pages/dataset/detail/components/Test.tsx index d8694fa5b..19b30f671 100644 --- a/projects/app/src/pages/dataset/detail/components/Test.tsx +++ b/projects/app/src/pages/dataset/detail/components/Test.tsx @@ -186,7 +186,7 @@ const Test = ({ datasetId }: { datasetId: string }) => { ]} gridGap={4} > - {datasetTestItem?.results.map((item) => ( + {datasetTestItem?.results.map((item, index) => ( { }} > + + # {index + 1} + { /> {item.score.toFixed(4)} - + {item.q} {item.a} diff --git a/projects/app/src/service/moduleDispatch/kb/search.ts b/projects/app/src/service/moduleDispatch/kb/search.ts index e7bdecc25..30215f483 100644 --- a/projects/app/src/service/moduleDispatch/kb/search.ts +++ b/projects/app/src/service/moduleDispatch/kb/search.ts @@ -52,7 +52,7 @@ export async function dispatchKBSearch(props: Record): Promise '[${ vectors[0] }]') * -1 AS score from ${PgDatasetTableName} where user_id='${ diff --git a/projects/app/src/service/pg.ts b/projects/app/src/service/pg.ts index 3d8d55119..fb80aeaf8 100644 --- a/projects/app/src/service/pg.ts +++ b/projects/app/src/service/pg.ts @@ -195,7 +195,7 @@ export async function initPg() { q TEXT NOT NULL, a TEXT ); - CREATE INDEX IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 16, ef_construction = 64); + CREATE INDEX IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 24, ef_construction = 48); `); console.log('init pg successful');