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
a9db5b57
authored
Nov 18, 2024
by
Archer
Committed by
GitHub
Nov 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add training retry time (#3187)
* feat: add training retry time * remoce log
parent
fdb3720b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
7 deletions
+49
-7
packages/service/core/dataset/training/schema.ts
+6
-1
projects/app/src/pages/api/core/dataset/update.ts
+34
-1
projects/app/src/service/events/generateQA.ts
+5
-3
projects/app/src/service/events/generateVector.ts
+4
-2
No files found.
packages/service/core/dataset/training/schema.ts
View file @
a9db5b57
...
...
@@ -51,6 +51,11 @@ const TrainingDataSchema = new Schema({
type
:
Date
,
default
:
()
=>
new
Date
(
'2000/1/1'
)
},
retryCount
:
{
type
:
Number
,
default
:
5
},
model
:
{
// ai model
type
:
String
,
...
...
@@ -97,7 +102,7 @@ try {
// lock training data(teamId); delete training data
TrainingDataSchema
.
index
({
teamId
:
1
,
datasetId
:
1
});
// get training data and sort
TrainingDataSchema
.
index
({
mode
:
1
,
lockTime
:
1
,
weight
:
-
1
});
TrainingDataSchema
.
index
({
mode
:
1
,
retryCount
:
1
,
lockTime
:
1
,
weight
:
-
1
});
TrainingDataSchema
.
index
({
expireAt
:
1
},
{
expireAfterSeconds
:
7
*
24
*
60
*
60
});
// 7 days
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
projects/app/src/pages/api/core/dataset/update.ts
View file @
a9db5b57
...
...
@@ -9,7 +9,7 @@ import {
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
CommonErrEnum
}
from
'@fastgpt/global/common/error/code/common'
;
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
{
DatasetTypeEnum
}
from
'@fastgpt/global/core/dataset/constants'
;
import
{
DatasetTypeEnum
,
TrainingModeEnum
}
from
'@fastgpt/global/core/dataset/constants'
;
import
{
ClientSession
}
from
'mongoose'
;
import
{
parseParentIdInMongo
}
from
'@fastgpt/global/common/parentFolder/utils'
;
import
{
mongoSessionRun
}
from
'@fastgpt/service/common/mongo/sessionRun'
;
...
...
@@ -21,6 +21,7 @@ import {
import
{
authUserPer
}
from
'@fastgpt/service/support/permission/user/auth'
;
import
{
TeamWritePermissionVal
}
from
'@fastgpt/global/support/permission/user/constant'
;
import
{
DatasetErrEnum
}
from
'@fastgpt/global/common/error/code/dataset'
;
import
{
MongoDatasetTraining
}
from
'@fastgpt/service/core/dataset/training/schema'
;
export
type
DatasetUpdateQuery
=
{};
export
type
DatasetUpdateResponse
=
any
;
...
...
@@ -84,6 +85,12 @@ async function handler(
const
isFolder
=
dataset
.
type
===
DatasetTypeEnum
.
folder
;
updateTraining
({
teamId
:
dataset
.
teamId
,
datasetId
:
id
,
agentModel
:
agentModel
?.
model
});
const
onUpdate
=
async
(
session
?:
ClientSession
)
=>
{
await
MongoDataset
.
findByIdAndUpdate
(
id
,
...
...
@@ -137,3 +144,29 @@ async function handler(
}
}
export
default
NextAPI
(
handler
);
async
function
updateTraining
({
teamId
,
datasetId
,
agentModel
}:
{
teamId
:
string
;
datasetId
:
string
;
agentModel
?:
string
;
})
{
if
(
!
agentModel
)
return
;
await
MongoDatasetTraining
.
updateMany
(
{
teamId
,
datasetId
,
mode
:
{
$in
:
[
TrainingModeEnum
.
qa
,
TrainingModeEnum
.
auto
]
}
},
{
$set
:
{
model
:
agentModel
,
retryCount
:
5
}
}
);
}
projects/app/src/service/events/generateQA.ts
View file @
a9db5b57
...
...
@@ -39,11 +39,13 @@ export async function generateQA(): Promise<any> {
try
{
const
data
=
await
MongoDatasetTraining
.
findOneAndUpdate
(
{
lockTime
:
{
$lte
:
addMinutes
(
new
Date
(),
-
6
)
},
mode
:
TrainingModeEnum
.
qa
mode
:
TrainingModeEnum
.
qa
,
retryCount
:
{
$gte
:
0
},
lockTime
:
{
$lte
:
addMinutes
(
new
Date
(),
-
6
)
}
},
{
lockTime
:
new
Date
()
lockTime
:
new
Date
(),
$inc
:
{
retryCount
:
-
1
}
}
)
.
select
({
...
...
projects/app/src/service/events/generateVector.ts
View file @
a9db5b57
...
...
@@ -39,10 +39,12 @@ export async function generateVector(): Promise<any> {
const
data
=
await
MongoDatasetTraining
.
findOneAndUpdate
(
{
mode
:
TrainingModeEnum
.
chunk
,
lockTime
:
{
$lte
:
addMinutes
(
new
Date
(),
-
1
)
}
retryCount
:
{
$gte
:
0
},
lockTime
:
{
$lte
:
addMinutes
(
new
Date
(),
-
6
)
}
},
{
lockTime
:
new
Date
()
lockTime
:
new
Date
(),
$inc
:
{
retryCount
:
-
1
}
}
).
select
({
_id
:
1
,
...
...
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