v4.6.6-fix (#676)

This commit is contained in:
Archer
2024-01-02 14:18:51 +08:00
committed by GitHub
parent d645a7406b
commit 2e75851b02
179 changed files with 279 additions and 5964 deletions

View File

@@ -401,6 +401,7 @@
"metadata": {
"Chunk Size": "Chunk Size",
"Createtime": "Create Time",
"Raw text length": "Raw text length",
"Read Metadata": "Read Metadata",
"Training Type": "Training Type",
"Updatetime": "Update Time",

View File

@@ -401,6 +401,7 @@
"metadata": {
"Chunk Size": "分割大小",
"Createtime": "创建时间",
"Raw text length": "原文长度",
"Read Metadata": "查看元数据",
"Training Type": "训练模式",
"Updatetime": "更新时间",

View File

@@ -9,7 +9,8 @@ const unAuthPage: { [key: string]: boolean } = {
'/login/provider': true,
'/login/fastlogin': true,
'/appStore': true,
'/chat/share': true
'/chat/share': true,
'/tools/price': true
};
const Auth = ({ children }: { children: JSX.Element }) => {

View File

@@ -25,14 +25,16 @@ const pcUnShowLayoutRoute: Record<string, boolean> = {
'/login/fastlogin': true,
'/chat/share': true,
'/app/edit': true,
'/chat': true
'/chat': true,
'/tools/price': true
};
const phoneUnShowLayoutRoute: Record<string, boolean> = {
'/': true,
'/login': true,
'/login/provider': true,
'/login/fastlogin': true,
'/chat/share': true
'/chat/share': true,
'/tools/price': true
};
const Layout = ({ children }: { children: JSX.Element }) => {

View File

@@ -54,7 +54,7 @@ const ApiKeyTable = ({ tips, appId }: { tips: string; appId?: string }) => {
const { Loading } = useLoading();
const theme = useTheme();
const { copyData } = useCopyData();
const [baseUrl, setBaseUrl] = useState('https://fastgpt.run/api');
const [baseUrl, setBaseUrl] = useState('https://fastgpt.in/api');
const [editData, setEditData] = useState<EditProps>();
const [apiKey, setApiKey] = useState('');

View File

@@ -137,27 +137,29 @@ ${audioSpeechModelList
borderRadius={'50%'}
onClick={onClose}
/>
<Box py={[0, 10]} px={[5, '50px']} overflow={'overlay'} h={'100%'}>
{list.map((item) => (
<Box
display={['block', 'flex']}
key={item.title}
w={'100%'}
mb={4}
pb={6}
_notLast={{
borderBottom: '1px',
borderBottomColor: 'borderColor.high'
}}
>
<Box fontSize={'xl'} fontWeight={'bold'} mb={1} flex={'1 0 0'}>
{item.title}
<Box overflow={'overlay'} h={'100%'}>
<Box py={[0, 10]} px={5} mx={'auto'} maxW={'1200px'}>
{list.map((item) => (
<Box
display={['block', 'flex']}
key={item.title}
w={'100%'}
mb={4}
pb={6}
_notLast={{
borderBottom: '1px',
borderBottomColor: 'borderColor.high'
}}
>
<Box fontSize={'xl'} fontWeight={'bold'} mb={1} flex={'1 0 0'}>
{item.title}
</Box>
<Box w={['100%', '410px']}>
<Markdown source={item.md}></Markdown>
</Box>
</Box>
<Box w={['100%', '410px']}>
<Markdown source={item.md}></Markdown>
</Box>
</Box>
))}
))}
</Box>
</Box>
</Box>,
// @ts-ignore

View File

@@ -3,7 +3,7 @@ import { jsonRes } from '@fastgpt/service/common/response';
import { connectToDatabase } from '@/service/mongo';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { uploadFile } from '@fastgpt/service/common/file/gridfs/controller';
import { getUploadModel } from '@fastgpt/service/common/file/upload/multer';
import { getUploadModel, removeFilesByPaths } from '@fastgpt/service/common/file/upload/multer';
/**
* Creates the multer uploader
@@ -13,10 +13,15 @@ const upload = getUploadModel({
});
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
let filePaths: string[] = [];
try {
const { files, bucketName, metadata } = await upload.doUpload(req, res);
filePaths = files.map((file) => file.path);
await connectToDatabase();
const { userId, teamId, tmbId } = await authCert({ req, authToken: true });
const { files, bucketName, metadata } = await upload.doUpload(req, res);
if (!bucketName) {
throw new Error('bucketName is empty');
@@ -48,6 +53,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
error
});
}
removeFilesByPaths(filePaths);
}
export const config = {

View File

@@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@fastgpt/service/common/response';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { withNextCors } from '@fastgpt/service/common/middle/cors';
import { getUploadModel } from '@fastgpt/service/common/file/upload/multer';
import { getUploadModel, removeFilesByPaths } from '@fastgpt/service/common/file/upload/multer';
import fs from 'fs';
import { getAIApi } from '@fastgpt/service/core/ai/config';
import { pushWhisperBill } from '@/service/support/wallet/bill/push';
@@ -12,12 +12,16 @@ const upload = getUploadModel({
});
export default withNextCors(async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
let filePaths: string[] = [];
try {
const {
files,
metadata: { duration, shareId }
} = await upload.doUpload<{ duration: number; shareId?: string }>(req, res);
filePaths = files.map((file) => file.path);
const { teamId, tmbId } = await authCert({ req, authToken: true });
if (!global.whisperModel) {
@@ -53,6 +57,8 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
error: err
});
}
removeFilesByPaths(filePaths);
});
export const config = {

View File

@@ -581,7 +581,7 @@ const CollectionCard = () => {
_hover={{
color: 'primary.500',
'& .icon': {
bg: 'myGray.100'
bg: 'myGray.200'
}
}}
>

View File

@@ -145,6 +145,10 @@ const DataCard = () => {
label: t('core.dataset.collection.metadata.Updatetime'),
value: formatTime2YMDHM(collection.updateTime)
},
{
label: t('core.dataset.collection.metadata.Raw text length'),
value: collection.rawTextLength ?? '-'
},
{
label: t('core.dataset.collection.metadata.Training Type'),
value: t(DatasetCollectionTrainingTypeMap[collection.trainingType]?.label)

View File

@@ -180,6 +180,7 @@ const Provider = ({
chunkSize: chunkLen,
trainingType: collectionTrainingType,
qaPrompt: mode === TrainingModeEnum.qa ? prompt : '',
rawTextLength: file.rawText.length,
hashRawText: hashStr(file.rawText)
});

View File

@@ -106,7 +106,7 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
const isCommunityVersion = feConfigs?.show_register === false && feConfigs?.show_git;
return (
<>
<Flex flexDirection={'column'} h={'100%'}>
<Flex alignItems={'center'}>
<Flex
w={['48px', '56px']}
@@ -203,48 +203,49 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
</Flex>
</>
)}
{/* oauth */}
{feConfigs?.show_register && oAuthList.length > 0 && (
<>
<Box mt={'80px'} position={'relative'}>
<Divider />
<AbsoluteCenter bg="white" px="4" color={'myGray.500'}>
or
</AbsoluteCenter>
</Box>
<Box mt={8}>
{oAuthList.map((item) => (
<Box key={item.provider} _notFirst={{ mt: 4 }}>
<Button
variant={'whitePrimary'}
w={'100%'}
h={'42px'}
leftIcon={
<MyIcon
name={item.icon as any}
w={'20px'}
cursor={'pointer'}
color={'myGray.800'}
/>
}
onClick={() => {
setLoginStore({
provider: item.provider,
lastRoute,
state: state.current
});
router.replace(item.redirectUrl, '_self');
}}
>
{item.label}
</Button>
</Box>
))}
</Box>
</>
)}
</Box>
</>
<Box flex={1} />
{/* oauth */}
{feConfigs?.show_register && oAuthList.length > 0 && (
<>
<Box position={'relative'}>
<Divider />
<AbsoluteCenter bg="white" px="4" color={'myGray.500'}>
or
</AbsoluteCenter>
</Box>
<Box mt={8}>
{oAuthList.map((item) => (
<Box key={item.provider} _notFirst={{ mt: 4 }}>
<Button
variant={'whitePrimary'}
w={'100%'}
h={'42px'}
leftIcon={
<MyIcon
name={item.icon as any}
w={'20px'}
cursor={'pointer'}
color={'myGray.800'}
/>
}
onClick={() => {
setLoginStore({
provider: item.provider,
lastRoute,
state: state.current
});
router.replace(item.redirectUrl, '_self');
}}
>
{item.label}
</Button>
</Box>
))}
</Box>
</>
)}
</Flex>
);
};

View File

@@ -76,21 +76,20 @@ const Login = () => {
<Flex
flexDirection={'column'}
w={['100%', 'auto']}
h={['100%', '80%']}
maxH={'700px'}
h={['100%', '700px']}
maxH={'90vh'}
bg={'white'}
px={['5vw', '88px']}
py={'64px'}
py={'5vh'}
borderRadius={[0, '24px']}
boxShadow={[
'',
'0px 0px 1px 0px rgba(19, 51, 107, 0.20), 0px 32px 64px -12px rgba(19, 51, 107, 0.20)'
]}
>
<Box w={['100%', '380px']}>
<Box w={['100%', '380px']} flex={'1 0 0'}>
<DynamicComponent type={pageType} />
</Box>
{feConfigs?.concatMd && (
<Box
mt={8}

View File

@@ -0,0 +1,10 @@
import React from 'react';
import Price from '@/components/support/wallet/Price';
import { useRouter } from 'next/router';
const PriceBox = () => {
const router = useRouter();
return <Price onClose={router.back} />;
};
export default PriceBox;

View File

@@ -7,6 +7,7 @@ import { moduleTemplatesFlat } from '@/web/core/modules/template/system';
import { adaptRole_Message2Chat } from '@fastgpt/global/core/chat/adapt';
import { EDGE_TYPE } from '@fastgpt/global/core/module/node/constant';
import { UserInputModule } from '@fastgpt/global/core/module/template/system/userInput';
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constant';
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
export const gptMessage2ChatType = (messages: ChatMessageItemType[]): ChatItemType[] => {
@@ -34,7 +35,16 @@ export const textAdaptGptResponse = ({
object: '',
created: 0,
model,
choices: [{ delta: text === null ? {} : { content: text }, index: 0, finish_reason }]
choices: [
{
delta:
text === null
? {}
: { role: ChatCompletionRequestMessageRoleEnum.Assistant, content: text },
index: 0,
finish_reason
}
]
});
};