mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +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}`}
|
||||
strategy="afterInteractive"
|
||||
></Script>
|
||||
<Script
|
||||
src={`https://www.google.com/recaptcha/api.js?render=${googleVerKey}`}
|
||||
strategy="afterInteractive"
|
||||
></Script>
|
||||
</>
|
||||
)}
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
@@ -153,7 +153,8 @@ A2:
|
||||
sendInform({
|
||||
type: 'system',
|
||||
title: 'QA 任务中止',
|
||||
content: '由于账号余额不足,QA 任务中止,重新充值后将会继续。',
|
||||
content:
|
||||
'由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
|
||||
userId
|
||||
});
|
||||
console.log('余额不足,暂停向量生成任务');
|
||||
|
@@ -104,7 +104,8 @@ export async function generateVector(): Promise<any> {
|
||||
sendInform({
|
||||
type: 'system',
|
||||
title: '索引生成任务中止',
|
||||
content: '由于账号余额不足,索引生成任务中止,重新充值后将会继续。',
|
||||
content:
|
||||
'由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
|
||||
userId
|
||||
});
|
||||
console.log('余额不足,暂停向量生成任务');
|
||||
|
@@ -15,6 +15,10 @@ const TrainingDataSchema = new Schema({
|
||||
ref: 'kb',
|
||||
required: true
|
||||
},
|
||||
expireAt: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
},
|
||||
lockTime: {
|
||||
type: Date,
|
||||
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> =
|
||||
models['trainingData'] || model('trainingData', TrainingDataSchema);
|
||||
|
@@ -176,7 +176,7 @@ export const getApiKey = async ({
|
||||
userId: string;
|
||||
mustPay?: boolean;
|
||||
}) => {
|
||||
const user = await User.findById(userId);
|
||||
const user = await User.findById(userId, 'openaiKey balance');
|
||||
if (!user) {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
}
|
||||
@@ -207,7 +207,6 @@ export const getApiKey = async ({
|
||||
// 有自己的key
|
||||
if (!mustPay && keyMap[model].userOpenAiKey) {
|
||||
return {
|
||||
user,
|
||||
userOpenAiKey: keyMap[model].userOpenAiKey,
|
||||
systemAuthKey: ''
|
||||
};
|
||||
@@ -219,7 +218,6 @@ export const getApiKey = async ({
|
||||
}
|
||||
|
||||
return {
|
||||
user,
|
||||
userOpenAiKey: '',
|
||||
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;
|
||||
userId: string;
|
||||
kbId: string;
|
||||
expireAt: Date;
|
||||
lockTime: Date;
|
||||
mode: `${TrainingModeEnum}`;
|
||||
prompt: string;
|
||||
|
Reference in New Issue
Block a user