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
1e02544c
authored
Oct 29, 2024
by
Archer
Committed by
GitHub
Oct 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: reset milvus (#3013)
parent
98771284
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
162 additions
and
17 deletions
+162
-17
docSite/content/zh-cn/docs/development/upgrading/4812.md
+22
-9
packages/service/core/dataset/training/schema.ts
+1
-1
pnpm-lock.yaml
+0
-0
projects/app/src/pages/api/admin/resetMilvus.ts
+139
-0
projects/app/src/pages/api/core/dataset/collection/scrollList.ts
+0
-5
projects/app/src/pages/api/core/dataset/training/rebuildEmbedding.ts
+0
-1
projects/app/src/service/events/generateVector.ts
+0
-1
No files found.
docSite/content/zh-cn/docs/development/upgrading/4812.md
View file @
1e02544c
...
...
@@ -14,13 +14,13 @@ weight: 812
### 2. 修改镜像
-
更新 FastGPT 镜像 tag: v4.8.12-beta
-
更新 FastGPT
商业版镜像 tag: v4.8.12-beta
-
更新 FastGPT
管理端镜像 tag: v4.8.12-beta (fastgpt-pro镜像)
-
Sandbox 镜像,可以不更新
### 3. 商业版执行初始化
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的
`rootkey`
;{{host}} 替换成
**FastGPT
商业版
域名**
。
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的
`rootkey`
;{{host}} 替换成
**FastGPT
管理端
域名**
。
```
bash
curl
--location
--request
POST
'https://{{host}}/api/admin/init/4812'
\
...
...
@@ -30,6 +30,18 @@ curl --location --request POST 'https://{{host}}/api/admin/init/4812' \
会初始化应用和知识库的成员组数据。
### 4. 重构 Milvus 数据
由于 js int64 精度丢失问题,之前私有化使用 milvus 或者 zilliz 的用户,如果存在数据精度丢失的问题,需要重构 Milvus 数据。(可以查看 dataset_datas 表中,indexes 中的 dataId 是否末尾精度丢失)。使用 PG 的用户不需要操作。
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的
`rootkey`
;{{host}} 替换成
**FastGPT 主域名**
。
```
bash
curl
--location
--request
POST
'https://{{host}}/api/admin/resetMilvus'
\
--header
'rootkey: {{rootkey}}'
\
--header
'Content-Type: application/json'
```
## 更新说明
1.
新增 - 全局变量支持数字类型,支持配置默认值和部分输入框参数。
...
...
@@ -45,10 +57,11 @@ curl --location --request POST 'https://{{host}}/api/admin/init/4812' \
11.
新增 - HTTP 节点支持 JSONPath 表达式
12.
新增 - 应用和知识库支持成员组配置权限
13.
优化 - 循环节点支持选择外部节点的变量
14.
修复 - 文件后缀判断,去除 query 影响。
15.
修复 - AI 响应为空时,会造成 LLM 历史记录合并。
16.
修复 - 用户交互节点未阻塞流程。
17.
修复 - 新建 APP,有时候会导致空指针报错。
18.
修复 - 拥有多个循环节点时,错误运行。
19.
修复 - 循环节点中修改变量,无法传递。
20.
修复 - 非 stream 模式,嵌套子应用/插件执行时无法获取子应用响应。
14.
优化 - Docx 文件读取中, HTML to Markdown 优化,提高速度和大幅度降低内存消耗。
15.
修复 - 文件后缀判断,去除 query 影响。
16.
修复 - AI 响应为空时,会造成 LLM 历史记录合并。
17.
修复 - 用户交互节点未阻塞流程。
18.
修复 - 新建 APP,有时候会导致空指针报错。
19.
修复 - 拥有多个循环节点时,错误运行。
20.
修复 - 循环节点中修改变量,无法传递。
21.
修复 - 非 stream 模式,嵌套子应用/插件执行时无法获取子应用响应。
packages/service/core/dataset/training/schema.ts
View file @
1e02544c
...
...
@@ -63,7 +63,7 @@ const TrainingDataSchema = new Schema({
},
q
:
{
type
:
String
,
required
:
true
default
:
''
},
a
:
{
type
:
String
,
...
...
pnpm-lock.yaml
View file @
1e02544c
This diff is collapsed.
Click to expand it.
projects/app/src/pages/api/admin/resetMilvus.ts
0 → 100644
View file @
1e02544c
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
MilvusCtrl
}
from
'@fastgpt/service/common/vectorStore/milvus/class'
;
import
{
DatasetVectorTableName
}
from
'@fastgpt/service/common/vectorStore/constants'
;
import
{
authCert
}
from
'@fastgpt/service/support/permission/auth/common'
;
import
{
MongoDatasetData
}
from
'@fastgpt/service/core/dataset/data/schema'
;
import
{
mongoSessionRun
}
from
'@fastgpt/service/common/mongo/sessionRun'
;
import
{
MongoDatasetTraining
}
from
'@fastgpt/service/core/dataset/training/schema'
;
import
{
TrainingModeEnum
}
from
'@fastgpt/global/core/dataset/constants'
;
import
{
MongoDataset
}
from
'@fastgpt/service/core/dataset/schema'
;
import
{
DatasetSchemaType
}
from
'@fastgpt/global/core/dataset/type'
;
import
{
delay
}
from
'@fastgpt/global/common/system/utils'
;
import
{
startTrainingQueue
}
from
'@/service/core/dataset/training/utils'
;
export
type
resetMilvusQuery
=
{};
export
type
resetMilvusBody
=
{};
export
type
resetMilvusResponse
=
{};
async
function
handler
(
req
:
ApiRequestProps
<
resetMilvusBody
,
resetMilvusQuery
>
,
res
:
ApiResponseType
<
any
>
):
Promise
<
resetMilvusResponse
>
{
await
authCert
({
req
,
authRoot
:
true
});
// 删除 milvus DatasetVectorTableName 表
const
milvus
=
new
MilvusCtrl
();
const
client
=
await
milvus
.
getClient
();
await
client
.
dropCollection
({
collection_name
:
DatasetVectorTableName
});
await
milvus
.
init
();
const
datasets
=
await
MongoDataset
.
find
({},
'_id name teamId tmbId vectorModel'
).
lean
();
let
dataLength
=
0
;
const
rebuild
=
async
(
dataset
:
DatasetSchemaType
,
retry
=
3
)
=>
{
try
{
return
mongoSessionRun
(
async
(
session
)
=>
{
// 更新数据状态进入重建
const
data
=
await
MongoDatasetData
.
updateMany
(
{
teamId
:
dataset
.
teamId
,
datasetId
:
dataset
.
_id
},
{
$set
:
{
rebuilding
:
true
}
},
{
session
}
);
dataLength
+=
data
.
matchedCount
;
console
.
log
(
data
.
matchedCount
,
'=-=-'
);
// 插入数据进入训练库
const
max
=
global
.
systemEnv
?.
vectorMaxProcess
||
10
;
const
arr
=
new
Array
(
max
*
2
).
fill
(
0
);
for
await
(
const
_
of
arr
)
{
try
{
const
hasNext
=
await
mongoSessionRun
(
async
(
session
)
=>
{
// get next dataset.data
const
data
=
await
MongoDatasetData
.
findOneAndUpdate
(
{
rebuilding
:
true
},
{
$unset
:
{
rebuilding
:
null
},
updateTime
:
new
Date
()
},
{
session
}
).
select
({
_id
:
1
,
collectionId
:
1
,
teamId
:
1
,
tmbId
:
1
,
datasetId
:
1
});
if
(
data
)
{
await
MongoDatasetTraining
.
create
(
[
{
teamId
:
dataset
.
teamId
,
tmbId
:
dataset
.
tmbId
,
datasetId
:
dataset
.
_id
,
collectionId
:
data
.
collectionId
,
mode
:
TrainingModeEnum
.
chunk
,
model
:
dataset
.
vectorModel
,
dataId
:
data
.
_id
}
],
{
session
}
);
}
return
!!
data
;
});
if
(
!
hasNext
)
{
break
;
}
}
catch
(
error
)
{
console
.
log
(
error
,
'='
);
}
}
});
}
catch
(
error
)
{
console
.
log
(
error
);
await
delay
(
500
);
if
(
retry
>
0
)
{
return
rebuild
(
dataset
,
retry
-
1
);
}
}
};
// 重置所有集合进入 rebuild 状态
(
async
()
=>
{
for
await
(
const
dataset
of
datasets
)
{
await
rebuild
(
dataset
);
}
startTrainingQueue
();
console
.
log
(
'Total reset length:'
,
dataLength
);
})();
return
{};
}
export
default
NextAPI
(
handler
);
projects/app/src/pages/api/core/dataset/collection/scrollList.ts
View file @
1e02544c
...
...
@@ -4,7 +4,6 @@ import { NextAPI } from '@/service/middleware/entry';
import
{
DatasetTrainingCollectionName
}
from
'@fastgpt/service/core/dataset/training/schema'
;
import
{
Types
}
from
'@fastgpt/service/common/mongo'
;
import
{
DatasetDataCollectionName
}
from
'@fastgpt/service/core/dataset/data/schema'
;
import
{
startTrainingQueue
}
from
'@/service/core/dataset/training/utils'
;
import
{
MongoDatasetCollection
}
from
'@fastgpt/service/core/dataset/collection/schema'
;
import
{
DatasetCollectionTypeEnum
}
from
'@fastgpt/global/core/dataset/constants'
;
import
{
CommonErrEnum
}
from
'@fastgpt/global/common/error/code/common'
;
...
...
@@ -178,10 +177,6 @@ async function handler(
}))
);
if
(
data
.
find
((
item
)
=>
item
.
trainingAmount
>
0
))
{
startTrainingQueue
();
}
// count collections
return
{
list
:
data
,
...
...
projects/app/src/pages/api/core/dataset/training/rebuildEmbedding.ts
View file @
1e02544c
...
...
@@ -117,7 +117,6 @@ async function handler(req: ApiRequestProps<rebuildEmbeddingBody>): Promise<Resp
billId
,
mode
:
TrainingModeEnum
.
chunk
,
model
:
vectorModel
,
q
:
'1'
,
dataId
:
data
.
_id
}
],
...
...
projects/app/src/service/events/generateVector.ts
View file @
1e02544c
...
...
@@ -190,7 +190,6 @@ const rebuildData = async ({
billId
:
trainingData
.
billId
,
mode
:
TrainingModeEnum
.
chunk
,
model
:
trainingData
.
model
,
q
:
'1'
,
dataId
:
newRebuildingData
.
_id
}
],
...
...
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