From 9e07a1ba7cc43fce1c325b068f7719c88a72a87e Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 20 Oct 2023 12:41:49 +0100 Subject: [PATCH] add additional config --- .../Postgres_Existing/Postgres_Exisiting.ts | 18 ++++++++++++++++++ .../Postgres_Upsert/Postgres_Upsert.ts | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts b/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts index 91e371da4..c08874322 100644 --- a/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts +++ b/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts @@ -65,6 +65,13 @@ class Postgres_Existing_VectorStores implements INode { additionalParams: true, optional: true }, + { + label: 'Additional Configuration', + name: 'additionalConfig', + type: 'json', + additionalParams: true, + optional: true + }, { label: 'Top K', name: 'topK', @@ -96,11 +103,22 @@ class Postgres_Existing_VectorStores implements INode { const _tableName = nodeData.inputs?.tableName as string const tableName = _tableName ? _tableName : 'documents' const embeddings = nodeData.inputs?.embeddings as Embeddings + const additionalConfig = nodeData.inputs?.additionalConfig as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string 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 = { + ...additionalConfiguration, type: 'postgres', host: nodeData.inputs?.host as string, port: nodeData.inputs?.port as number, diff --git a/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts b/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts index 7df0ecb1f..bc16a0525 100644 --- a/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts +++ b/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts @@ -72,6 +72,13 @@ class PostgresUpsert_VectorStores implements INode { additionalParams: true, optional: true }, + { + label: 'Additional Configuration', + name: 'additionalConfig', + type: 'json', + additionalParams: true, + optional: true + }, { label: 'Top K', name: 'topK', @@ -104,11 +111,22 @@ class PostgresUpsert_VectorStores implements INode { const tableName = _tableName ? _tableName : 'documents' const docs = nodeData.inputs?.document as Document[] const embeddings = nodeData.inputs?.embeddings as Embeddings + const additionalConfig = nodeData.inputs?.additionalConfig as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string 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 = { + ...additionalConfiguration, type: 'postgres', host: nodeData.inputs?.host as string, port: nodeData.inputs?.port as number,