4.8.10 test (#2401)

* perf: i18n

* perf: i18n and img tip

* perf: readme

* perf: hide tool ai response

* fix: copy app

* fix: parse image url regx

* perf: folder collection forbid update
This commit is contained in:
Archer
2024-08-16 13:09:17 +08:00
committed by GitHub
parent 5bf0dd0ef1
commit 61347d9aaa
29 changed files with 358 additions and 296 deletions

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { Box, Flex, useTheme, Grid, type GridProps, theme, Image, Radio } from '@chakra-ui/react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { Box, Flex, useTheme, Grid, type GridProps, Radio } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import { useToast } from '@fastgpt/web/hooks/useToast';
import Avatar from '@fastgpt/web/components/common/Avatar';
// @ts-ignore
interface Props extends GridProps {
@@ -53,7 +53,8 @@ const MyRadio = ({
{...(value === item.value
? {
borderColor: 'primary.400',
bg: 'primary.50'
bg: 'primary.50',
color: 'primary.600'
}
: {
bg: 'myWhite.300',
@@ -74,11 +75,7 @@ const MyRadio = ({
>
{!!item.icon && (
<>
{item.icon.startsWith('/') ? (
<Image src={item.icon} mr={'14px'} w={iconSize} alt={''} fill={'primary.600'} />
) : (
<MyIcon mr={'14px'} name={item.icon as any} w={iconSize} fill={'primary.600'} />
)}
<Avatar src={item.icon} w={iconSize} mr={'14px'} />
</>
)}
<Box pr={hiddenCircle ? 0 : 2} flex={'1 0 0'}>

View File

@@ -136,7 +136,7 @@ const AIChatSettingsModal = ({
{t('common:core.ai.Support tool')}
<QuestionTip ml={1} label={t('common:core.module.template.AI support tool tip')} />
</Box>
<Box flex={1} ml={'10px'}>
<Box flex={1}>
{selectedModel?.toolChoice || selectedModel?.functionCall
? t('common:common.support')
: t('common:common.not_support')}

View File

@@ -50,7 +50,7 @@ const ChatFunctionTip = ({ type }: { type: `${FnTypeEnum}` }) => {
imgUrl: '/imgs/app/welcome.svg'
},
[FnTypeEnum.file]: {
icon: '/imgs/app/welcome-icon.svg',
icon: '/imgs/app/fileinput.svg',
title: t('app:file_upload'),
desc: t('app:file_upload_tip'),
imgUrl: '/imgs/app/fileUploadPlaceholder.png'

View File

@@ -112,13 +112,13 @@ const StandardPlanContentList = ({
{!!planContent.permissionReRank && (
<Flex alignItems={'center'}>
<MyIcon name={'price/right'} w={'16px'} mr={3} />
<Box color={'myGray.600'}>{t('chat:rearrangement')}</Box>
<Box color={'myGray.600'}>{t('support.wallet.subscription.rerank')}</Box>
</Flex>
)}
{!!planContent.permissionWebsiteSync && (
<Flex alignItems={'center'}>
<MyIcon name={'price/right'} w={'16px'} mr={3} />
<Box color={'myGray.600'}>{t('chat:web_site_sync')}</Box>
<Box color={'myGray.600'}>{t('support.wallet.subscription.web_site_sync')}</Box>
</Flex>
)}
</Grid>

View File

@@ -39,6 +39,7 @@ async function handler(
type: app.type,
modules: app.modules,
edges: app.edges,
chatConfig: app.chatConfig,
teamId: app.teamId,
tmbId,
pluginData: app.pluginData

View File

@@ -5,6 +5,10 @@ import { NextAPI } from '@/service/middleware/entry';
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
import { ApiRequestProps } from '@fastgpt/service/type/next';
import { DatasetCollectionTypeEnum } from '@fastgpt/global/core/dataset/constants';
import { ClientSession } from '@fastgpt/service/common/mongo';
import { CollectionWithDatasetType } from '@fastgpt/global/core/dataset/type';
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
export type UpdateDatasetCollectionParams = {
id: string;
@@ -14,6 +18,52 @@ export type UpdateDatasetCollectionParams = {
forbid?: boolean;
};
// Set folder collection children forbid status
const updateFolderChildrenForbid = async ({
collection,
forbid,
session
}: {
collection: CollectionWithDatasetType;
forbid: boolean;
session: ClientSession;
}) => {
// 从 collection 作为 parent 进行递归查找,找到它所有 forbid 与它相同的 child
const find = async (parentId: string): Promise<string[]> => {
const children = await MongoDatasetCollection.find(
{
teamId: collection.teamId,
datasetId: collection.datasetId,
parentId
},
'_id',
{ session }
);
const idList = children.map((item) => String(item._id));
const IdChildren = (await Promise.all(idList.map(find))).flat();
return [...idList, ...IdChildren];
};
const allChildrenIdList = await find(collection._id);
await MongoDatasetCollection.updateMany(
{
_id: { $in: allChildrenIdList }
},
{
$set: {
forbid
}
},
{
session
}
);
};
async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
const { id, parentId, name, tags, forbid } = req.body;
@@ -22,7 +72,7 @@ async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
}
// 凭证校验
await authDatasetCollection({
const { collection } = await authDatasetCollection({
req,
authToken: true,
authApiKey: true,
@@ -30,15 +80,32 @@ async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
per: WritePermissionVal
});
const updateFields: Record<string, any> = {
...(parentId !== undefined && { parentId: parentId || null }),
...(name && { name, updateTime: getCollectionUpdateTime({ name }) }),
...(tags && { tags }),
...(forbid !== undefined && { forbid })
};
await mongoSessionRun(async (session) => {
await MongoDatasetCollection.updateOne(
{
_id: id
},
{
$set: {
...(parentId !== undefined && { parentId: parentId || null }),
...(name && { name, updateTime: getCollectionUpdateTime({ name }) }),
...(tags && { tags }),
...(forbid !== undefined && { forbid })
}
},
{
session
}
);
await MongoDatasetCollection.findByIdAndUpdate(id, {
$set: updateFields
// Folder update forbid
if (collection.type === DatasetCollectionTypeEnum.folder && forbid !== undefined) {
await updateFolderChildrenForbid({
collection,
forbid,
session
});
}
});
}

View File

@@ -76,7 +76,7 @@ const FeiShuEditModal = ({
<Box color="myGray.600">{t('publish:feishu_api')}</Box>
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/feishu-bot')}
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/feishu')}
target={'_blank'}
ml={2}
color={'primary.500'}

View File

@@ -75,7 +75,7 @@ const OffiAccountEditModal = ({
</Box>
<Flex p={8} minH={['auto', '400px']} flexDirection="column" gap={6}>
<Flex alignItems="center">
<Box color="myGray.600">{t('publish:official_account.api')}</Box>
<Box color="myGray.600">{t('publish:official_account.params')}</Box>
{feConfigs?.docUrl && (
<Link
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/official_account')}

View File

@@ -36,8 +36,9 @@ const SelectAiModelRender = ({ item, inputs = [], nodeId }: RenderInputProps) =>
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatMaxToken)?.value ?? 2048,
temperature:
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatTemperature)?.value ?? 1,
isResponseAnswerText:
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true,
isResponseAnswerText: inputs.find(
(input) => input.key === NodeInputKeyEnum.aiChatIsResponseText
)?.value,
aiChatVision:
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatVision)?.value ?? true
}),

View File

@@ -95,6 +95,10 @@ export async function getServerSideProps(context: any) {
const datasetId = context?.query?.datasetId;
return {
props: { currentTab, datasetId, ...(await serviceSideProps(context, ['dataset', 'file'])) }
props: {
currentTab,
datasetId,
...(await serviceSideProps(context, ['dataset', 'file', 'user']))
}
};
}