diff --git a/client/src/pages/_app.tsx b/client/src/pages/_app.tsx
index 39a64037a..f0a842dfe 100644
--- a/client/src/pages/_app.tsx
+++ b/client/src/pages/_app.tsx
@@ -60,10 +60,6 @@ function App({ Component, pageProps }: AppProps) {
src={`https://www.recaptcha.net/recaptcha/api.js?render=${googleVerKey}`}
strategy="afterInteractive"
>
-
>
)}
diff --git a/client/src/service/events/generateQA.ts b/client/src/service/events/generateQA.ts
index 733c040b4..85b3727ae 100644
--- a/client/src/service/events/generateQA.ts
+++ b/client/src/service/events/generateQA.ts
@@ -153,7 +153,8 @@ A2:
sendInform({
type: 'system',
title: 'QA 任务中止',
- content: '由于账号余额不足,QA 任务中止,重新充值后将会继续。',
+ content:
+ '由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
userId
});
console.log('余额不足,暂停向量生成任务');
diff --git a/client/src/service/events/generateVector.ts b/client/src/service/events/generateVector.ts
index 2234fddac..99c3a43d0 100644
--- a/client/src/service/events/generateVector.ts
+++ b/client/src/service/events/generateVector.ts
@@ -104,7 +104,8 @@ export async function generateVector(): Promise {
sendInform({
type: 'system',
title: '索引生成任务中止',
- content: '由于账号余额不足,索引生成任务中止,重新充值后将会继续。',
+ content:
+ '由于账号余额不足,索引生成任务中止,重新充值后将会继续。暂停的任务将在 7 天后被删除。',
userId
});
console.log('余额不足,暂停向量生成任务');
diff --git a/client/src/service/models/trainingData.ts b/client/src/service/models/trainingData.ts
index a364ac9ff..65fd96c78 100644
--- a/client/src/service/models/trainingData.ts
+++ b/client/src/service/models/trainingData.ts
@@ -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 =
models['trainingData'] || model('trainingData', TrainingDataSchema);
diff --git a/client/src/service/utils/auth.ts b/client/src/service/utils/auth.ts
index 029f17e62..638b9b764 100644
--- a/client/src/service/utils/auth.ts
+++ b/client/src/service/utils/auth.ts
@@ -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
};
diff --git a/client/src/types/mongoSchema.d.ts b/client/src/types/mongoSchema.d.ts
index 19c961ba3..ac5d194a7 100644
--- a/client/src/types/mongoSchema.d.ts
+++ b/client/src/types/mongoSchema.d.ts
@@ -70,6 +70,7 @@ export interface TrainingDataSchema {
_id: string;
userId: string;
kbId: string;
+ expireAt: Date;
lockTime: Date;
mode: `${TrainingModeEnum}`;
prompt: string;