Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f56a339a
authored
Jun 25, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: index
parent
68eca25d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
9 deletions
+18
-9
client/src/pages/_app.tsx
+0
-4
client/src/service/events/generateQA.ts
+2
-1
client/src/service/events/generateVector.ts
+2
-1
client/src/service/models/trainingData.ts
+12
-0
client/src/service/utils/auth.ts
+1
-3
client/src/types/mongoSchema.d.ts
+1
-0
No files found.
client/src/pages/_app.tsx
View file @
f56a339a
...
@@ -60,10 +60,6 @@ function App({ Component, pageProps }: AppProps) {
...
@@ -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
}
>
...
...
client/src/service/events/generateQA.ts
View file @
f56a339a
...
@@ -153,7 +153,8 @@ A2:
...
@@ -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
(
'余额不足,暂停向量生成任务'
);
...
...
client/src/service/events/generateVector.ts
View file @
f56a339a
...
@@ -104,7 +104,8 @@ export async function generateVector(): Promise<any> {
...
@@ -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
(
'余额不足,暂停向量生成任务'
);
...
...
client/src/service/models/trainingData.ts
View file @
f56a339a
...
@@ -15,6 +15,10 @@ const TrainingDataSchema = new Schema({
...
@@ -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({
...
@@ -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
);
client/src/service/utils/auth.ts
View file @
f56a339a
...
@@ -176,7 +176,7 @@ export const getApiKey = async ({
...
@@ -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 ({
...
@@ -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 ({
...
@@ -219,7 +218,6 @@ export const getApiKey = async ({
}
}
return
{
return
{
user
,
userOpenAiKey
:
''
,
userOpenAiKey
:
''
,
systemAuthKey
:
keyMap
[
model
].
systemAuthKey
systemAuthKey
:
keyMap
[
model
].
systemAuthKey
};
};
...
...
client/src/types/mongoSchema.d.ts
View file @
f56a339a
...
@@ -70,6 +70,7 @@ export interface TrainingDataSchema {
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment