add additional config
This commit is contained in:
parent
26898a2230
commit
9e07a1ba7c
|
|
@ -65,6 +65,13 @@ class Postgres_Existing_VectorStores implements INode {
|
||||||
additionalParams: true,
|
additionalParams: true,
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Additional Configuration',
|
||||||
|
name: 'additionalConfig',
|
||||||
|
type: 'json',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Top K',
|
label: 'Top K',
|
||||||
name: 'topK',
|
name: 'topK',
|
||||||
|
|
@ -96,11 +103,22 @@ class Postgres_Existing_VectorStores implements INode {
|
||||||
const _tableName = nodeData.inputs?.tableName as string
|
const _tableName = nodeData.inputs?.tableName as string
|
||||||
const tableName = _tableName ? _tableName : 'documents'
|
const tableName = _tableName ? _tableName : 'documents'
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
|
const additionalConfig = nodeData.inputs?.additionalConfig as string
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
const topK = nodeData.inputs?.topK as string
|
const topK = nodeData.inputs?.topK as string
|
||||||
const k = topK ? parseFloat(topK) : 4
|
const k = topK ? parseFloat(topK) : 4
|
||||||
|
|
||||||
|
let additionalConfiguration = {}
|
||||||
|
if (additionalConfig) {
|
||||||
|
try {
|
||||||
|
additionalConfiguration = typeof additionalConfig === 'object' ? additionalConfig : JSON.parse(additionalConfig)
|
||||||
|
} catch (exception) {
|
||||||
|
throw new Error('Invalid JSON in the Additional Configuration: ' + exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const postgresConnectionOptions = {
|
const postgresConnectionOptions = {
|
||||||
|
...additionalConfiguration,
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
host: nodeData.inputs?.host as string,
|
host: nodeData.inputs?.host as string,
|
||||||
port: nodeData.inputs?.port as number,
|
port: nodeData.inputs?.port as number,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,13 @@ class PostgresUpsert_VectorStores implements INode {
|
||||||
additionalParams: true,
|
additionalParams: true,
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Additional Configuration',
|
||||||
|
name: 'additionalConfig',
|
||||||
|
type: 'json',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Top K',
|
label: 'Top K',
|
||||||
name: 'topK',
|
name: 'topK',
|
||||||
|
|
@ -104,11 +111,22 @@ class PostgresUpsert_VectorStores implements INode {
|
||||||
const tableName = _tableName ? _tableName : 'documents'
|
const tableName = _tableName ? _tableName : 'documents'
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const docs = nodeData.inputs?.document as Document[]
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
|
const additionalConfig = nodeData.inputs?.additionalConfig as string
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
const topK = nodeData.inputs?.topK as string
|
const topK = nodeData.inputs?.topK as string
|
||||||
const k = topK ? parseFloat(topK) : 4
|
const k = topK ? parseFloat(topK) : 4
|
||||||
|
|
||||||
|
let additionalConfiguration = {}
|
||||||
|
if (additionalConfig) {
|
||||||
|
try {
|
||||||
|
additionalConfiguration = typeof additionalConfig === 'object' ? additionalConfig : JSON.parse(additionalConfig)
|
||||||
|
} catch (exception) {
|
||||||
|
throw new Error('Invalid JSON in the Additional Configuration: ' + exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const postgresConnectionOptions = {
|
const postgresConnectionOptions = {
|
||||||
|
...additionalConfiguration,
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
host: nodeData.inputs?.host as string,
|
host: nodeData.inputs?.host as string,
|
||||||
port: nodeData.inputs?.port as number,
|
port: nodeData.inputs?.port as number,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue