Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tls support to milvus #3068

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 97 additions & 2 deletions packages/components/nodes/vectorstores/Milvus/Milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Milvus_VectorStores implements INode {
constructor() {
this.label = 'Milvus'
this.name = 'milvus'
this.version = 2.0
this.version = 2.1
this.type = 'Milvus'
this.icon = 'milvus.svg'
this.category = 'Vector Stores'
Expand Down Expand Up @@ -65,6 +65,13 @@ class Milvus_VectorStores implements INode {
name: 'milvusCollection',
type: 'string'
},
{
label: 'Milvus Partition Name',
name: 'milvusPartition',
default: '_default',
type: 'string',
optional: true
},
{
label: 'File Upload',
name: 'fileUpload',
Expand Down Expand Up @@ -103,6 +110,46 @@ class Milvus_VectorStores implements INode {
type: 'number',
additionalParams: true,
optional: true
},
{
label: 'Secure',
name: 'secure',
type: 'boolean',
optional: true,
description: 'Enable secure connection to Milvus server',
additionalParams: true
},
{
label: 'Client PEM Path',
name: 'clientPemPath',
type: 'string',
optional: true,
description: 'Path to the client PEM file',
additionalParams: true
},
{
label: 'Client Key Path',
name: 'clientKeyPath',
type: 'string',
optional: true,
description: 'Path to the client key file',
additionalParams: true
},
{
label: 'CA PEM Path',
name: 'caPemPath',
type: 'string',
optional: true,
description: 'Path to the root PEM file',
additionalParams: true
},
{
label: 'Server Name',
name: 'serverName',
type: 'string',
optional: true,
description: 'Server name for the secure connection',
additionalParams: true
}
]
this.outputs = [
Expand Down Expand Up @@ -136,10 +183,34 @@ class Milvus_VectorStores implements INode {
const milvusUser = getCredentialParam('milvusUser', credentialData, nodeData)
const milvusPassword = getCredentialParam('milvusPassword', credentialData, nodeData)

// tls
const secure = nodeData.inputs?.secure as boolean
const clientPemPath = nodeData.inputs?.clientPemPath as string
const clientKeyPath = nodeData.inputs?.clientKeyPath as string
const caPemPath = nodeData.inputs?.caPemPath as string
const serverName = nodeData.inputs?.serverName as string

// partition
const partitionName = nodeData.inputs?.milvusPartition ?? '_default'

// init MilvusLibArgs
const milVusArgs: MilvusLibArgs = {
url: address,
collectionName: collectionName
collectionName: collectionName,
partitionName: partitionName
}

if (secure) {
milVusArgs.clientConfig = {
address: address,
ssl: secure,
tls: {
rootCertPath: caPemPath,
certChainPath: clientPemPath,
privateKeyPath: clientKeyPath,
serverName: serverName
}
}
}

if (milvusUser) milVusArgs.username = milvusUser
Expand Down Expand Up @@ -194,13 +265,37 @@ class Milvus_VectorStores implements INode {
const milvusUser = getCredentialParam('milvusUser', credentialData, nodeData)
const milvusPassword = getCredentialParam('milvusPassword', credentialData, nodeData)

// tls
const secure = nodeData.inputs?.secure as boolean
const clientPemPath = nodeData.inputs?.clientPemPath as string
const clientKeyPath = nodeData.inputs?.clientKeyPath as string
const caPemPath = nodeData.inputs?.caPemPath as string
const serverName = nodeData.inputs?.serverName as string

// partition
const partitionName = nodeData.inputs?.milvusPartition ?? '_default'

// init MilvusLibArgs
const milVusArgs: MilvusLibArgs = {
url: address,
collectionName: collectionName,
partitionName: partitionName,
textField: textField
}

if (secure) {
milVusArgs.clientConfig = {
address: address,
ssl: secure,
tls: {
rootCertPath: caPemPath,
certChainPath: clientPemPath,
privateKeyPath: clientKeyPath,
serverName: serverName
}
}
}

if (milvusUser) milVusArgs.username = milvusUser
if (milvusPassword) milVusArgs.password = milvusPassword

Expand Down
Loading