mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-21 03:10:50 +00:00
perf: index
This commit is contained in:
@@ -60,10 +60,6 @@ function App({ Component, pageProps }: AppProps) {
|
|||||||
src={`https://www.recaptcha.net/recaptcha/api.js?render=${googleVerKey}`}
|
src={`https://www.recaptcha.net/recaptcha/api.js?render=${googleVerKey}`}
|
||||||
strategy="afterInteractive"
|
strategy="afterInteractive"
|
||||||
></Script>
|
></Script>
|
||||||
<Script
|
|
||||||
src={`https://www.google.com/recaptcha/api.js?render=${googleVerKey}`}
|
|
||||||
strategy="afterInteractive"
|
|
||||||
></Script>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
|
@@ -153,7 +153,8 @@ A2:
|
|||||||
sendInform({
|
sendInform({
|
||||||
type: 'system',
|
type: 'system',
|
||||||
title: 'QA 任务中止',
|
title: 'QA 任务中止',
|
||||||
content: '由于账号余额不足,QA 任务中止,重新充值后将会继续。',
|
content:
|
||||||
|
'由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
|
||||||
userId
|
userId
|
||||||
});
|
});
|
||||||
console.log('余额不足,暂停向量生成任务');
|
console.log('余额不足,暂停向量生成任务');
|
||||||
|
@@ -104,7 +104,8 @@ export async function generateVector(): Promise<any> {
|
|||||||
sendInform({
|
sendInform({
|
||||||
type: 'system',
|
type: 'system',
|
||||||
title: '索引生成任务中止',
|
title: '索引生成任务中止',
|
||||||
content: '由于账号余额不足,索引生成任务中止,重新充值后将会继续。',
|
content:
|
||||||
|
'由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
|
||||||
userId
|
userId
|
||||||
});
|
});
|
||||||
console.log('余额不足,暂停向量生成任务');
|
console.log('余额不足,暂停向量生成任务');
|
||||||
|
@@ -15,6 +15,10 @@ const TrainingDataSchema = new Schema({
|
|||||||
ref: 'kb',
|
ref: 'kb',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
expireAt: {
|
||||||
|
type: Date,
|
||||||
|
default: () => new Date()
|
||||||
|
},
|
||||||
lockTime: {
|
lockTime: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: () => new Date('2000/1/1')
|
default: () => new Date('2000/1/1')
|
||||||
@@ -44,5 +48,13 @@ const TrainingDataSchema = new Schema({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
TrainingDataSchema.index({ lockTime: 1 });
|
||||||
|
TrainingDataSchema.index({ userId: 1 });
|
||||||
|
TrainingDataSchema.index({ expireAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 });
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
export const TrainingData: MongoModel<TrainingDateType> =
|
export const TrainingData: MongoModel<TrainingDateType> =
|
||||||
models['trainingData'] || model('trainingData', TrainingDataSchema);
|
models['trainingData'] || model('trainingData', TrainingDataSchema);
|
||||||
|
@@ -176,7 +176,7 @@ export const getApiKey = async ({
|
|||||||
userId: string;
|
userId: string;
|
||||||
mustPay?: boolean;
|
mustPay?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const user = await User.findById(userId);
|
const user = await User.findById(userId, 'openaiKey balance');
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,6 @@ export const getApiKey = async ({
|
|||||||
// 有自己的key
|
// 有自己的key
|
||||||
if (!mustPay && keyMap[model].userOpenAiKey) {
|
if (!mustPay && keyMap[model].userOpenAiKey) {
|
||||||
return {
|
return {
|
||||||
user,
|
|
||||||
userOpenAiKey: keyMap[model].userOpenAiKey,
|
userOpenAiKey: keyMap[model].userOpenAiKey,
|
||||||
systemAuthKey: ''
|
systemAuthKey: ''
|
||||||
};
|
};
|
||||||
@@ -219,7 +218,6 @@ export const getApiKey = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
|
||||||
userOpenAiKey: '',
|
userOpenAiKey: '',
|
||||||
systemAuthKey: keyMap[model].systemAuthKey
|
systemAuthKey: keyMap[model].systemAuthKey
|
||||||
};
|
};
|
||||||
|
1
client/src/types/mongoSchema.d.ts
vendored
1
client/src/types/mongoSchema.d.ts
vendored
@@ -70,6 +70,7 @@ export interface TrainingDataSchema {
|
|||||||
_id: string;
|
_id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
kbId: string;
|
kbId: string;
|
||||||
|
expireAt: Date;
|
||||||
lockTime: Date;
|
lockTime: Date;
|
||||||
mode: `${TrainingModeEnum}`;
|
mode: `${TrainingModeEnum}`;
|
||||||
prompt: string;
|
prompt: string;
|
||||||
|
Reference in New Issue
Block a user