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
4e3d817b
authored
Oct 28, 2024
by
Finley Ge
Committed by
GitHub
Oct 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: milvus (#3004)
parent
78a85bf8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletions
+12
-1
packages/service/common/vectorStore/milvus/class.ts
+12
-1
No files found.
packages/service/common/vectorStore/milvus/class.ts
View file @
4e3d817b
...
@@ -13,6 +13,7 @@ import type {
...
@@ -13,6 +13,7 @@ import type {
}
from
'../controller.d'
;
}
from
'../controller.d'
;
import
{
delay
}
from
'@fastgpt/global/common/system/utils'
;
import
{
delay
}
from
'@fastgpt/global/common/system/utils'
;
import
{
addLog
}
from
'../../../common/system/log'
;
import
{
addLog
}
from
'../../../common/system/log'
;
import
{
customNanoid
}
from
'@fastgpt/global/common/string/tools'
;
export
class
MilvusCtrl
{
export
class
MilvusCtrl
{
constructor
()
{}
constructor
()
{}
...
@@ -63,7 +64,7 @@ export class MilvusCtrl {
...
@@ -63,7 +64,7 @@ export class MilvusCtrl {
name
:
'id'
,
name
:
'id'
,
data_type
:
DataType
.
Int64
,
data_type
:
DataType
.
Int64
,
is_primary_key
:
true
,
is_primary_key
:
true
,
autoID
:
true
autoID
:
false
// disable auto id, and we need to set id in insert
},
},
{
{
name
:
'vector'
,
name
:
'vector'
,
...
@@ -127,11 +128,21 @@ export class MilvusCtrl {
...
@@ -127,11 +128,21 @@ export class MilvusCtrl {
const
client
=
await
this
.
getClient
();
const
client
=
await
this
.
getClient
();
const
{
teamId
,
datasetId
,
collectionId
,
vector
,
retry
=
3
}
=
props
;
const
{
teamId
,
datasetId
,
collectionId
,
vector
,
retry
=
3
}
=
props
;
const
generateId
=
()
=>
{
// in js, the max safe integer is 2^53 - 1: 9007199254740991
// so we can generate a random number between 1-8 as the first digit
// and the rest 15 digits can be random
const
firstDigit
=
customNanoid
(
'12345678'
,
1
);
const
restDigits
=
customNanoid
(
'1234567890'
,
15
);
return
Number
(
`
${
firstDigit
}${
restDigits
}
`
);
};
const
id
=
generateId
();
try
{
try
{
const
result
=
await
client
.
insert
({
const
result
=
await
client
.
insert
({
collection_name
:
DatasetVectorTableName
,
collection_name
:
DatasetVectorTableName
,
data
:
[
data
:
[
{
{
id
,
vector
,
vector
,
teamId
:
String
(
teamId
),
teamId
:
String
(
teamId
),
datasetId
:
String
(
datasetId
),
datasetId
:
String
(
datasetId
),
...
...
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