Skip to content

Commit

Permalink
v4.5.1-3 (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Oct 24, 2023
1 parent 1942cb0 commit 1dca5ed
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 73 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

| | |
| ---------------------------------- | ---------------------------------- |
Expand Down Expand Up @@ -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. 联系方式:[email protected], [点击查看定价策略](https://doc.fastgpt.run/docs/commercial)
1 change: 0 additions & 1 deletion docSite/content/docs/installation/upgrading/45.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/workflow/examples/lab_appointment.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ HTTP 模块允许你调用任意 POST 类型的 HTTP 接口,从而实验一些
{
"moduleId": "zltb5l",
"name": "知识库搜索",
"flowType": "kbSearchNode",
"flowType": "datasetSearchNode",
"showStatus": true,
"position": {
"x": 1634.995464753433,
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/workflow/examples/op_question.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ weight: 144
{
"moduleId": "nkxlso",
"name": "知识库搜索",
"flowType": "kbSearchNode",
"flowType": "datasetSearchNode",
"showStatus": true,
"position": {
"x": 1542.6434554710224,
Expand Down
2 changes: 1 addition & 1 deletion projects/app/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"SystemParams": {
"vectorMaxProcess": 15,
"qaMaxProcess": 15,
"pgHNSWEfSearch ": 60
"pgHNSWEfSearch": 100
},
"ChatModels": [
{
Expand Down
8 changes: 7 additions & 1 deletion projects/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 7 additions & 1 deletion projects/app/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
119 changes: 74 additions & 45 deletions projects/app/src/components/ChatBox/QuoteModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 = [],
Expand All @@ -22,6 +25,7 @@ const QuoteModal = ({
onClose: () => void;
}) => {
const { t } = useTranslation();
const { isPc } = useSystemStore();
const theme = useTheme();
const router = useRouter();
const { toast } = useToast();
Expand Down Expand Up @@ -67,7 +71,7 @@ const QuoteModal = ({
title={
<>
知识库引用({rawSearch.length}条)
<Box fontSize={['xs', 'sm']} fontWeight={'normal'}>
<Box fontSize={'10px'} color={'myGray.500'} fontWeight={'normal'}>
注意: 修改知识库内容成功后,此处不会显示变更情况。点击编辑后,会显示知识库最新的内容。
</Box>
</>
Expand All @@ -89,58 +93,83 @@ const QuoteModal = ({
border={theme.borders.base}
_notLast={{ mb: 2 }}
position={'relative'}
_hover={{ '& .edit': { display: 'flex' } }}
overflow={'hidden'}
>
{!isShare && (
<Flex alignItems={'center'} mb={1}>
<Flex alignItems={'flex-end'} mb={1}>
<RawSourceText sourceName={item.sourceName} sourceId={item.sourceId} />
<Box flex={'1'} />
{item.score && (
<>
<Progress
mx={2}
w={['60px', '100px']}
value={item.score * 100}
size="sm"
borderRadius={'20px'}
colorScheme="gray"
border={theme.borders.base}
/>
<Box>{item.score.toFixed(4)}</Box>
</>
)}
<Box flex={1} />
<Link
as={NextLink}
display={'flex'}
alignItems={'center'}
color={'myBlue.600'}
href={`/dataset/detail?datasetId=${item.datasetId}&currentTab=dataCard&collectionId=${item.collectionId}`}
>
{t('core.dataset.Go Dataset')}
<MyIcon name={'rightArrowLight'} w={'10px'} />
</Link>
</Flex>
)}

<Box>{item.q}</Box>
<Box>{item.a}</Box>
{item.id && !isShare && (
<Box
className="edit"
display={'none'}
position={'absolute'}
right={0}
top={0}
bottom={0}
w={'40px'}
bg={'rgba(255,255,255,0.9)'}
alignItems={'center'}
justifyContent={'center'}
boxShadow={'-10px 0 10px rgba(255,255,255,1)'}
>
<MyIcon
name={'edit'}
w={'18px'}
h={'18px'}
cursor={'pointer'}
color={'myGray.600'}
_hover={{
color: 'myBlue.700'
}}
onClick={() => onclickEdit(item)}
/>
</Box>
{!isShare && (
<Flex alignItems={'center'} mt={2} gap={4}>
{isPc && (
<MyTooltip label={t('core.dataset.data.id')}>
<Flex border={theme.borders.base} px={3} borderRadius={'md'}>
# {item.id}
</Flex>
</MyTooltip>
)}
<MyTooltip label={t('core.dataset.Quote Length')}>
<Flex alignItems={'center'}>
<MyIcon name="common/text/t" w={'14px'} mr={1} color={'myGray.500'} />
{item.q.length + item.a.length}
</Flex>
</MyTooltip>
{!isShare && item.score && (
<MyTooltip label={t('core.dataset.Similarity')}>
<Flex alignItems={'center'}>
<MyIcon name={'kbTest'} w={'12px'} />
<Progress
mx={2}
w={['60px', '90px']}
value={item.score * 100}
size="sm"
borderRadius={'20px'}
colorScheme="gray"
border={theme.borders.base}
/>
<Box>{item.score.toFixed(4)}</Box>
</Flex>
</MyTooltip>
)}
<Box flex={1} />
{item.id && (
<MyTooltip label={t('core.dataset.data.Edit')}>
<Box
bg={'rgba(255,255,255,0.9)'}
alignItems={'center'}
justifyContent={'center'}
boxShadow={'-10px 0 10px rgba(255,255,255,1)'}
>
<MyIcon
name={'edit'}
w={['16px', '18px']}
h={['16px', '18px']}
cursor={'pointer'}
color={'myGray.600'}
_hover={{
color: 'myBlue.700'
}}
onClick={() => onclickEdit(item)}
/>
</Box>
</MyTooltip>
)}
</Flex>
)}
</Box>
))}
Expand Down
8 changes: 8 additions & 0 deletions projects/app/src/components/Icon/icons/common/text/t.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions projects/app/src/components/Icon/icons/light/rightArrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion projects/app/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/dataset/searchTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <#> '[${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const NodeCard = (props: Props) => {
name = '未知模块',
description,
minW = '300px',

moduleId
} = props;
const { onCopyNode, onDelNode } = useFlowStore();
Expand Down Expand Up @@ -81,7 +80,14 @@ const NodeCard = (props: Props) => {
);

return (
<Box minW={minW} bg={'white'} border={theme.borders.md} borderRadius={'md'} boxShadow={'sm'}>
<Box
minW={minW}
maxW={'500px'}
bg={'white'}
border={theme.borders.md}
borderRadius={'md'}
boxShadow={'sm'}
>
<Flex className="custom-drag-handle" px={4} py={3} alignItems={'center'}>
<Avatar src={logo} borderRadius={'md'} objectFit={'contain'} w={'30px'} h={'30px'} />
<Box ml={3} fontSize={'lg'} color={'myGray.600'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ var SelectDatasetRender = React.memo(function SelectDatasetRender({ item, module

return (
<>
<Grid gridTemplateColumns={'1fr 1fr'} gridGap={4}>
<Grid gridTemplateColumns={'repeat(2, minmax(0, 1fr))'} gridGap={4} w={'100%'}>
<Button h={'36px'} onClick={onOpenKbSelect}>
选择知识库
</Button>
Expand All @@ -512,7 +512,14 @@ var SelectDatasetRender = React.memo(function SelectDatasetRender({ item, module
borderRadius={'md'}
>
<Avatar src={item.avatar} w={'24px'}></Avatar>
<Box ml={3} fontWeight={'bold'} fontSize={['md', 'lg', 'xl']}>
<Box
ml={3}
flex={'1 0 0'}
w={0}
className="textEllipsis"
fontWeight={'bold'}
fontSize={['md', 'lg', 'xl']}
>
{item.name}
</Box>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
19 changes: 11 additions & 8 deletions projects/app/src/pages/dataset/detail/components/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const Test = ({ datasetId }: { datasetId: string }) => {
]}
gridGap={4}
>
{datasetTestItem?.results.map((item) => (
{datasetTestItem?.results.map((item, index) => (
<Box
key={item.id}
pb={2}
Expand Down Expand Up @@ -223,6 +223,15 @@ const Test = ({ datasetId }: { datasetId: string }) => {
}}
>
<Flex p={3} alignItems={'center'} color={'myGray.500'}>
<Box
border={theme.borders.base}
px={2}
fontSize={'sm'}
mr={1}
borderRadius={'md'}
>
# {index + 1}
</Box>
<MyIcon name={'kbTest'} w={'14px'} />
<Progress
mx={2}
Expand All @@ -234,13 +243,7 @@ const Test = ({ datasetId }: { datasetId: string }) => {
/>
<Box>{item.score.toFixed(4)}</Box>
</Flex>
<Box
px={2}
fontSize={'xs'}
color={'myGray.600'}
maxH={'200px'}
overflow={'overlay'}
>
<Box px={2} fontSize={'xs'} color={'myGray.600'}>
<Box>{item.q}</Box>
<Box>{item.a}</Box>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/service/moduleDispatch/kb/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function dispatchKBSearch(props: Record<string, any>): Promise<KBSe
// search kb
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 user_id='${
Expand Down
Loading

0 comments on commit 1dca5ed

Please sign in to comment.