From 09db08aace55f4cd969e5b29361911391255fd14 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 19:54:29 +0700 Subject: [PATCH 01/15] add Azure Chat OpenAI --- .../chatmodels/AzureChatOpenAI/Azure.svg | 5 + .../AzureChatOpenAI/AzureChatOpenAI.ts | 98 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 packages/components/nodes/chatmodels/AzureChatOpenAI/Azure.svg create mode 100644 packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/Azure.svg b/packages/components/nodes/chatmodels/AzureChatOpenAI/Azure.svg new file mode 100644 index 00000000..51eb6253 --- /dev/null +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/Azure.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts new file mode 100644 index 00000000..8692885d --- /dev/null +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -0,0 +1,98 @@ +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' +import { AzureOpenAIInput, ChatOpenAI } from 'langchain/chat_models/openai' + +class AzureChatOpenAI_ChatModels implements INode { + label: string + name: string + type: string + icon: string + category: string + description: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'Azure ChatOpenAI' + this.name = 'azureChatOpenAI' + this.type = 'AzureChatOpenAI' + this.icon = 'Azure.svg' + this.category = 'Chat Models' + this.description = 'Wrapper around Azure OpenAI large language models that use the Chat endpoint' + this.baseClasses = [this.type, ...getBaseClasses(ChatOpenAI)] + this.inputs = [ + { + label: 'Azure OpenAI Api Key', + name: 'azureOpenAIApiKey', + type: 'password' + }, + { + label: 'Temperature', + name: 'temperature', + type: 'number', + default: 0.9, + optional: true + }, + { + label: 'Azure OpenAI Api Instance Name', + name: 'azureOpenAIApiInstanceName', + type: 'string', + placeholder: 'YOUR-INSTANCE-NAME' + }, + { + label: 'Azure OpenAI Api Deployment Name', + name: 'azureOpenAIApiDeploymentName', + type: 'string', + placeholder: 'YOUR-DEPLOYMENT-NAME' + }, + { + label: 'Azure OpenAI Api Version', + name: 'azureOpenAIApiVersion', + type: 'string', + placeholder: 'YOUR-API-VERSION' + }, + { + label: 'Azure OpenAIApi Embeddings Deployment Name', + name: 'azureOpenAIApiEmbeddingsDeploymentName', + type: 'string', + placeholder: 'YOUR-EMBEDDINGS-NAME', + optional: true, + additionalParams: true + }, + { + label: 'azure OpenAI Api Completions Deployment Name', + name: 'azureOpenAIApiCompletionsDeploymentName', + type: 'string', + placeholder: 'YOUR-COMPLETIONS-NAME', + optional: true, + additionalParams: true + } + ] + } + + async init(nodeData: INodeData): Promise { + const azureOpenAIApiKey = nodeData.inputs?.azureOpenAIApiKey as string + const temperature = nodeData.inputs?.temperature as string + const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string + const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string + const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string + const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string + const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string + + const obj: Partial & { temperature?: number } = { + temperature: parseInt(temperature, 10), + azureOpenAIApiKey, + azureOpenAIApiInstanceName, + azureOpenAIApiDeploymentName, + azureOpenAIApiVersion + } + + if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName + if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName + + const model = new ChatOpenAI(obj) + return model + } +} + +module.exports = { nodeClass: AzureChatOpenAI_ChatModels } From 6ca0c364b9a9c32ade2919f107191fffb3c0718e Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 19:55:56 +0700 Subject: [PATCH 02/15] fix typo --- .../nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index 8692885d..a802b325 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -60,7 +60,7 @@ class AzureChatOpenAI_ChatModels implements INode { additionalParams: true }, { - label: 'azure OpenAI Api Completions Deployment Name', + label: 'Azure OpenAI Api Completions Deployment Name', name: 'azureOpenAIApiCompletionsDeploymentName', type: 'string', placeholder: 'YOUR-COMPLETIONS-NAME', From e1667067bebd01e5ebc945a3ba46a726d280d3fe Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 20:30:44 +0700 Subject: [PATCH 03/15] add OpenAIBaseInput interface --- .../nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index a802b325..d0833576 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -1,3 +1,4 @@ +import { OpenAIBaseInput } from 'langchain/dist/types/openai-types' import { INode, INodeData, INodeParams } from '../../../src/Interface' import { getBaseClasses } from '../../../src/utils' import { AzureOpenAIInput, ChatOpenAI } from 'langchain/chat_models/openai' @@ -79,7 +80,7 @@ class AzureChatOpenAI_ChatModels implements INode { const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string - const obj: Partial & { temperature?: number } = { + const obj: Partial & Partial = { temperature: parseInt(temperature, 10), azureOpenAIApiKey, azureOpenAIApiInstanceName, From 101cf2978c4dc6db7c379d93e109007b53f0722b Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 20:34:43 +0700 Subject: [PATCH 04/15] fix typo --- .../nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index d0833576..90ef3f9a 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -53,7 +53,7 @@ class AzureChatOpenAI_ChatModels implements INode { placeholder: 'YOUR-API-VERSION' }, { - label: 'Azure OpenAIApi Embeddings Deployment Name', + label: 'Azure OpenAI Api Embeddings Deployment Name', name: 'azureOpenAIApiEmbeddingsDeploymentName', type: 'string', placeholder: 'YOUR-EMBEDDINGS-NAME', From 908be47835e51e6cc20fea215932540974b7e6f4 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 21:00:36 +0700 Subject: [PATCH 05/15] add Azure OpenAI Embedding --- .../embeddings/AzureOpenAIEmbedding/Azure.svg | 5 + .../AzureOpenAIEmbedding.ts | 97 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 packages/components/nodes/embeddings/AzureOpenAIEmbedding/Azure.svg create mode 100644 packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/Azure.svg b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/Azure.svg new file mode 100644 index 00000000..51eb6253 --- /dev/null +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/Azure.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts new file mode 100644 index 00000000..51bd3a40 --- /dev/null +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts @@ -0,0 +1,97 @@ +import { AzureOpenAIInput } from 'langchain/chat_models/openai' +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' +import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from 'langchain/embeddings/openai' + +class AzureOpenAIEmbedding_Embeddings implements INode { + label: string + name: string + type: string + icon: string + category: string + description: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'Azure OpenAI Embeddings' + this.name = 'azureOpenAIEmbeddings' + this.type = 'AzureOpenAIEmbeddings' + this.icon = 'Azure.svg' + this.category = 'Embeddings' + this.description = 'Azure OpenAI API to generate embeddings for a given text' + this.baseClasses = [this.type, ...getBaseClasses(OpenAIEmbeddings)] + this.inputs = [ + { + label: 'Azure OpenAI Api Key', + name: 'azureOpenAIApiKey', + type: 'password' + }, + { + label: 'Azure OpenAI Api Instance Name', + name: 'azureOpenAIApiInstanceName', + type: 'string', + placeholder: 'YOUR-INSTANCE-NAME' + }, + { + label: 'Azure OpenAI Api Deployment Name', + name: 'azureOpenAIApiDeploymentName', + type: 'string', + placeholder: 'YOUR-DEPLOYMENT-NAME' + }, + { + label: 'Azure OpenAI Api Version', + name: 'azureOpenAIApiVersion', + type: 'string', + placeholder: 'YOUR-API-VERSION' + }, + { + label: 'Strip New Lines', + name: 'stripNewLines', + type: 'boolean', + optional: true, + additionalParams: true + }, + { + label: 'Batch Size', + name: 'batchSize', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', + optional: true, + additionalParams: true + } + ] + } + + async init(nodeData: INodeData): Promise { + const azureOpenAIApiKey = nodeData.inputs?.azureOpenAIApiKey as string + const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string + const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string + const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string + const stripNewLines = nodeData.inputs?.stripNewLines as boolean + const batchSize = nodeData.inputs?.batchSize as string + const timeout = nodeData.inputs?.timeout as string + + const obj: Partial & Partial = { + azureOpenAIApiKey, + azureOpenAIApiInstanceName, + azureOpenAIApiDeploymentName, + azureOpenAIApiVersion + } + + if (stripNewLines) obj.stripNewLines = stripNewLines + if (batchSize) obj.batchSize = parseInt(batchSize, 10) + if (timeout) obj.timeout = parseInt(timeout, 10) + + const model = new OpenAIEmbeddings(obj) + return model + } +} + +module.exports = { nodeClass: AzureOpenAIEmbedding_Embeddings } From c9c53b5387ff359d4db3d4887085676398435875 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 10 May 2023 21:35:20 +0700 Subject: [PATCH 06/15] add Azure Open AI --- .../nodes/llms/Azure OpenAI/Azure.svg | 5 + .../nodes/llms/Azure OpenAI/AzureOpenAI.ts | 98 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 packages/components/nodes/llms/Azure OpenAI/Azure.svg create mode 100644 packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts diff --git a/packages/components/nodes/llms/Azure OpenAI/Azure.svg b/packages/components/nodes/llms/Azure OpenAI/Azure.svg new file mode 100644 index 00000000..51eb6253 --- /dev/null +++ b/packages/components/nodes/llms/Azure OpenAI/Azure.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts new file mode 100644 index 00000000..3faa884d --- /dev/null +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -0,0 +1,98 @@ +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' +import { AzureOpenAIInput, OpenAI, OpenAIInput } from 'langchain/llms/openai' + +class AzureOpenAI_LLMs implements INode { + label: string + name: string + type: string + icon: string + category: string + description: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'Azure OpenAI' + this.name = 'azureOpenAI' + this.type = 'AzureOpenAI' + this.icon = 'Azure.svg' + this.category = 'LLMs' + this.description = 'Wrapper around Azure OpenAI large language models' + this.baseClasses = [this.type, ...getBaseClasses(OpenAI)] + this.inputs = [ + { + label: 'Azure OpenAI Api Key', + name: 'azureOpenAIApiKey', + type: 'password' + }, + { + label: 'Temperature', + name: 'temperature', + type: 'number', + default: 0.9, + optional: true + }, + { + label: 'Azure OpenAI Api Instance Name', + name: 'azureOpenAIApiInstanceName', + type: 'string', + placeholder: 'YOUR-INSTANCE-NAME' + }, + { + label: 'Azure OpenAI Api Deployment Name', + name: 'azureOpenAIApiDeploymentName', + type: 'string', + placeholder: 'YOUR-DEPLOYMENT-NAME' + }, + { + label: 'Azure OpenAI Api Version', + name: 'azureOpenAIApiVersion', + type: 'string', + placeholder: 'YOUR-API-VERSION' + }, + { + label: 'Azure OpenAI Api Embeddings Deployment Name', + name: 'azureOpenAIApiEmbeddingsDeploymentName', + type: 'string', + placeholder: 'YOUR-EMBEDDINGS-NAME', + optional: true, + additionalParams: true + }, + { + label: 'Azure OpenAI Api Completions Deployment Name', + name: 'azureOpenAIApiCompletionsDeploymentName', + type: 'string', + placeholder: 'YOUR-COMPLETIONS-NAME', + optional: true, + additionalParams: true + } + ] + } + + async init(nodeData: INodeData): Promise { + const azureOpenAIApiKey = nodeData.inputs?.azureOpenAIApiKey as string + const temperature = nodeData.inputs?.temperature as string + const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string + const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string + const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string + const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string + const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string + + const obj: Partial & Partial = { + temperature: parseInt(temperature, 10), + azureOpenAIApiKey, + azureOpenAIApiInstanceName, + azureOpenAIApiDeploymentName, + azureOpenAIApiVersion + } + + if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName + if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName + + const model = new OpenAI(obj) + return model + } +} + +module.exports = { nodeClass: AzureOpenAI_LLMs } From b0e938708780e5129819b6d91958e21740af297f Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 08:43:00 +0700 Subject: [PATCH 07/15] add modelName selection into Azure --- .../AzureChatOpenAI/AzureChatOpenAI.ts | 35 +++++++++++++++++++ .../AzureOpenAIEmbedding.ts | 19 ++++++++++ .../nodes/llms/Azure OpenAI/AzureOpenAI.ts | 31 ++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index 90ef3f9a..da98a07e 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -27,6 +27,39 @@ class AzureChatOpenAI_ChatModels implements INode { name: 'azureOpenAIApiKey', type: 'password' }, + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'gpt-4', + name: 'gpt-4' + }, + { + label: 'gpt-4-0314', + name: 'gpt-4-0314' + }, + { + label: 'gpt-4-32k', + name: 'gpt-4-32k' + }, + { + label: 'gpt-4-32k-0314', + name: 'gpt-4-32k-0314' + }, + { + label: 'gpt-3.5-turbo', + name: 'gpt-3.5-turbo' + }, + { + label: 'gpt-3.5-turbo-0301', + name: 'gpt-3.5-turbo-0301' + } + ], + default: 'gpt-3.5-turbo', + optional: true + }, { label: 'Temperature', name: 'temperature', @@ -73,6 +106,7 @@ class AzureChatOpenAI_ChatModels implements INode { async init(nodeData: INodeData): Promise { const azureOpenAIApiKey = nodeData.inputs?.azureOpenAIApiKey as string + const modelName = nodeData.inputs?.modelName as string const temperature = nodeData.inputs?.temperature as string const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string @@ -82,6 +116,7 @@ class AzureChatOpenAI_ChatModels implements INode { const obj: Partial & Partial = { temperature: parseInt(temperature, 10), + modelName, azureOpenAIApiKey, azureOpenAIApiInstanceName, azureOpenAIApiDeploymentName, diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts index 51bd3a40..305edfe5 100644 --- a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts @@ -27,6 +27,23 @@ class AzureOpenAIEmbedding_Embeddings implements INode { name: 'azureOpenAIApiKey', type: 'password' }, + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'text-embedding-ada-002', + name: 'text-embedding-ada-002' + }, + { + label: 'text-search-ada-doc-001', + name: 'text-search-ada-doc-001' + } + ], + default: 'text-embedding-ada-002', + optional: true + }, { label: 'Azure OpenAI Api Instance Name', name: 'azureOpenAIApiInstanceName', @@ -74,11 +91,13 @@ class AzureOpenAIEmbedding_Embeddings implements INode { const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string + const modelName = nodeData.inputs?.modelName as string const stripNewLines = nodeData.inputs?.stripNewLines as boolean const batchSize = nodeData.inputs?.batchSize as string const timeout = nodeData.inputs?.timeout as string const obj: Partial & Partial = { + modelName, azureOpenAIApiKey, azureOpenAIApiInstanceName, azureOpenAIApiDeploymentName, diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts index 3faa884d..0a22e680 100644 --- a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -26,6 +26,35 @@ class AzureOpenAI_LLMs implements INode { name: 'azureOpenAIApiKey', type: 'password' }, + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'text-davinci-003', + name: 'text-davinci-003' + }, + { + label: 'text-davinci-002', + name: 'text-davinci-002' + }, + { + label: 'text-curie-001', + name: 'text-curie-001' + }, + { + label: 'text-babbage-001', + name: 'text-babbage-001' + }, + { + label: 'text-ada-001', + name: 'text-ada-001' + } + ], + default: 'text-davinci-003', + optional: true + }, { label: 'Temperature', name: 'temperature', @@ -73,6 +102,7 @@ class AzureOpenAI_LLMs implements INode { async init(nodeData: INodeData): Promise { const azureOpenAIApiKey = nodeData.inputs?.azureOpenAIApiKey as string const temperature = nodeData.inputs?.temperature as string + const modelName = nodeData.inputs?.modelName as string const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string @@ -81,6 +111,7 @@ class AzureOpenAI_LLMs implements INode { const obj: Partial & Partial = { temperature: parseInt(temperature, 10), + modelName, azureOpenAIApiKey, azureOpenAIApiInstanceName, azureOpenAIApiDeploymentName, From 740a6124a0eeaa6eed75214d04f449566fc19103 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 08:58:32 +0700 Subject: [PATCH 08/15] fix RetrievalQAChain typo --- .../nodes/chains/RetrievalQAChain/RetrievalQAChain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/chains/RetrievalQAChain/RetrievalQAChain.ts b/packages/components/nodes/chains/RetrievalQAChain/RetrievalQAChain.ts index 2887643a..4b1381b4 100644 --- a/packages/components/nodes/chains/RetrievalQAChain/RetrievalQAChain.ts +++ b/packages/components/nodes/chains/RetrievalQAChain/RetrievalQAChain.ts @@ -15,7 +15,7 @@ class RetrievalQAChain_Chains implements INode { inputs: INodeParams[] constructor() { - this.label = 'RetrievalQA Chain' + this.label = 'Retrieval QA Chain' this.name = 'retrievalQAChain' this.type = 'RetrievalQAChain' this.icon = 'chain.svg' From cae4fb4e097511f68364540d3ff26a27c81fb21c Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 17:54:09 +0700 Subject: [PATCH 09/15] remove modelName in AzureOpenAIEmbedding --- .../AzureOpenAIEmbedding.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts index 305edfe5..51bd3a40 100644 --- a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts @@ -27,23 +27,6 @@ class AzureOpenAIEmbedding_Embeddings implements INode { name: 'azureOpenAIApiKey', type: 'password' }, - { - label: 'Model Name', - name: 'modelName', - type: 'options', - options: [ - { - label: 'text-embedding-ada-002', - name: 'text-embedding-ada-002' - }, - { - label: 'text-search-ada-doc-001', - name: 'text-search-ada-doc-001' - } - ], - default: 'text-embedding-ada-002', - optional: true - }, { label: 'Azure OpenAI Api Instance Name', name: 'azureOpenAIApiInstanceName', @@ -91,13 +74,11 @@ class AzureOpenAIEmbedding_Embeddings implements INode { const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string - const modelName = nodeData.inputs?.modelName as string const stripNewLines = nodeData.inputs?.stripNewLines as boolean const batchSize = nodeData.inputs?.batchSize as string const timeout = nodeData.inputs?.timeout as string const obj: Partial & Partial = { - modelName, azureOpenAIApiKey, azureOpenAIApiInstanceName, azureOpenAIApiDeploymentName, From abeacdf90637ec02ce4ebb117aa3a8586fb2651c Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 18:29:01 +0700 Subject: [PATCH 10/15] modify modelName options in AzureOpenAI --- .../nodes/llms/Azure OpenAI/AzureOpenAI.ts | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts index 0a22e680..d2517c44 100644 --- a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -36,20 +36,48 @@ class AzureOpenAI_LLMs implements INode { name: 'text-davinci-003' }, { - label: 'text-davinci-002', - name: 'text-davinci-002' + label: 'ada', + name: 'ada' }, { - label: 'text-curie-001', - name: 'text-curie-001' + label: 'text-ada-001', + name: 'text-ada-001' + }, + { + label: 'babbage', + name: 'babbage' }, { label: 'text-babbage-001', name: 'text-babbage-001' }, { - label: 'text-ada-001', - name: 'text-ada-001' + label: 'curie', + name: 'curie' + }, + { + label: 'text-curie-001', + name: 'text-curie-001' + }, + { + label: 'davinci', + name: 'davinci' + }, + { + label: 'text-davinci-001', + name: 'text-davinci-001' + }, + { + label: 'text-davinci-002', + name: 'text-davinci-002' + }, + { + label: 'text-davinci-fine-tune-002', + name: 'text-davinci-fine-tune-002' + }, + { + label: 'gpt-35-turbo', + name: 'gpt-35-turbo' } ], default: 'text-davinci-003', From 5c49a58985bd85698bc7d9a0f8aee35274f8cbab Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 18:31:53 +0700 Subject: [PATCH 11/15] modify modelName options in AzureChatOpenAI --- .../AzureChatOpenAI/AzureChatOpenAI.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index da98a07e..8d98e724 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -36,28 +36,16 @@ class AzureChatOpenAI_ChatModels implements INode { label: 'gpt-4', name: 'gpt-4' }, - { - label: 'gpt-4-0314', - name: 'gpt-4-0314' - }, { label: 'gpt-4-32k', name: 'gpt-4-32k' }, { - label: 'gpt-4-32k-0314', - name: 'gpt-4-32k-0314' - }, - { - label: 'gpt-3.5-turbo', - name: 'gpt-3.5-turbo' - }, - { - label: 'gpt-3.5-turbo-0301', - name: 'gpt-3.5-turbo-0301' + label: 'gpt-35-turbo', + name: 'gpt-35-turbo' } ], - default: 'gpt-3.5-turbo', + default: 'gpt-35-turbo', optional: true }, { From c596feb09a8830eb84288f3e85865273646ad855 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 20:26:09 +0700 Subject: [PATCH 12/15] modify input parameters --- .../AzureChatOpenAI/AzureChatOpenAI.ts | 63 +++++++++++---- .../AzureOpenAIEmbedding.ts | 14 +++- .../nodes/llms/Azure OpenAI/AzureOpenAI.ts | 81 +++++++++++++++---- 3 files changed, 128 insertions(+), 30 deletions(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index 8d98e724..3630a0bb 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -70,22 +70,51 @@ class AzureChatOpenAI_ChatModels implements INode { { label: 'Azure OpenAI Api Version', name: 'azureOpenAIApiVersion', - type: 'string', - placeholder: 'YOUR-API-VERSION' + type: 'options', + options: [ + { + label: '2023-03-15-preview', + name: '2023-03-15-preview' + }, + { + label: '2022-12-01', + name: '2022-12-01' + } + ], + default: '2023-03-15-preview' }, { - label: 'Azure OpenAI Api Embeddings Deployment Name', - name: 'azureOpenAIApiEmbeddingsDeploymentName', - type: 'string', - placeholder: 'YOUR-EMBEDDINGS-NAME', + label: 'Max Tokens', + name: 'maxTokens', + type: 'number', optional: true, additionalParams: true }, { - label: 'Azure OpenAI Api Completions Deployment Name', - name: 'azureOpenAIApiCompletionsDeploymentName', - type: 'string', - placeholder: 'YOUR-COMPLETIONS-NAME', + label: 'Top Probability', + name: 'topP', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Frequency Penalty', + name: 'frequencyPenalty', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Presence Penalty', + name: 'presencePenalty', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', optional: true, additionalParams: true } @@ -99,8 +128,11 @@ class AzureChatOpenAI_ChatModels implements INode { const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string - const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string - const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string + const maxTokens = nodeData.inputs?.maxTokens as string + const topP = nodeData.inputs?.topP as string + const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string + const presencePenalty = nodeData.inputs?.presencePenalty as string + const timeout = nodeData.inputs?.timeout as string const obj: Partial & Partial = { temperature: parseInt(temperature, 10), @@ -111,8 +143,11 @@ class AzureChatOpenAI_ChatModels implements INode { azureOpenAIApiVersion } - if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName - if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName + if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) + if (topP) obj.topP = parseInt(topP, 10) + if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) + if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) + if (timeout) obj.timeout = parseInt(timeout, 10) const model = new ChatOpenAI(obj) return model diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts index 51bd3a40..898e379f 100644 --- a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts @@ -42,8 +42,18 @@ class AzureOpenAIEmbedding_Embeddings implements INode { { label: 'Azure OpenAI Api Version', name: 'azureOpenAIApiVersion', - type: 'string', - placeholder: 'YOUR-API-VERSION' + type: 'options', + options: [ + { + label: '2023-03-15-preview', + name: '2023-03-15-preview' + }, + { + label: '2022-12-01', + name: '2022-12-01' + } + ], + default: '2023-03-15-preview' }, { label: 'Strip New Lines', diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts index d2517c44..47762cfd 100644 --- a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -105,22 +105,65 @@ class AzureOpenAI_LLMs implements INode { { label: 'Azure OpenAI Api Version', name: 'azureOpenAIApiVersion', - type: 'string', - placeholder: 'YOUR-API-VERSION' + type: 'options', + options: [ + { + label: '2023-03-15-preview', + name: '2023-03-15-preview' + }, + { + label: '2022-12-01', + name: '2022-12-01' + } + ], + default: '2023-03-15-preview' }, { - label: 'Azure OpenAI Api Embeddings Deployment Name', - name: 'azureOpenAIApiEmbeddingsDeploymentName', - type: 'string', - placeholder: 'YOUR-EMBEDDINGS-NAME', + label: 'Max Tokens', + name: 'maxTokens', + type: 'number', optional: true, additionalParams: true }, { - label: 'Azure OpenAI Api Completions Deployment Name', - name: 'azureOpenAIApiCompletionsDeploymentName', - type: 'string', - placeholder: 'YOUR-COMPLETIONS-NAME', + label: 'Top Probability', + name: 'topP', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Best Of', + name: 'bestOf', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Frequency Penalty', + name: 'frequencyPenalty', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Presence Penalty', + name: 'presencePenalty', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Batch Size', + name: 'batchSize', + type: 'number', + optional: true, + additionalParams: true + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', optional: true, additionalParams: true } @@ -134,8 +177,13 @@ class AzureOpenAI_LLMs implements INode { const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string - const azureOpenAIApiEmbeddingsDeploymentName = nodeData.inputs?.azureOpenAIApiEmbeddingsDeploymentName as string - const azureOpenAIApiCompletionsDeploymentName = nodeData.inputs?.azureOpenAIApiCompletionsDeploymentName as string + const maxTokens = nodeData.inputs?.maxTokens as string + const topP = nodeData.inputs?.topP as string + const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string + const presencePenalty = nodeData.inputs?.presencePenalty as string + const timeout = nodeData.inputs?.timeout as string + const batchSize = nodeData.inputs?.batchSize as string + const bestOf = nodeData.inputs?.bestOf as string const obj: Partial & Partial = { temperature: parseInt(temperature, 10), @@ -146,8 +194,13 @@ class AzureOpenAI_LLMs implements INode { azureOpenAIApiVersion } - if (azureOpenAIApiEmbeddingsDeploymentName) obj.azureOpenAIApiEmbeddingsDeploymentName = azureOpenAIApiEmbeddingsDeploymentName - if (azureOpenAIApiCompletionsDeploymentName) obj.azureOpenAIApiCompletionsDeploymentName = azureOpenAIApiCompletionsDeploymentName + if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) + if (topP) obj.topP = parseInt(topP, 10) + if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) + if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) + if (timeout) obj.timeout = parseInt(timeout, 10) + if (batchSize) obj.batchSize = parseInt(batchSize, 10) + if (bestOf) obj.bestOf = parseInt(bestOf, 10) const model = new OpenAI(obj) return model From 698aaa5c3bd7aff41a15984691792aed21010aa4 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 20:47:28 +0700 Subject: [PATCH 13/15] Chat Completions only support 2023-03-15-preview --- .../nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index 3630a0bb..c4942d83 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -75,10 +75,6 @@ class AzureChatOpenAI_ChatModels implements INode { { label: '2023-03-15-preview', name: '2023-03-15-preview' - }, - { - label: '2022-12-01', - name: '2022-12-01' } ], default: '2023-03-15-preview' From e55e1d4eaff1e0d0a139879fd744c8e4fc7a1786 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 20:54:32 +0700 Subject: [PATCH 14/15] remove unsupported params in AzureOpenAIEmbedding --- .../AzureOpenAIEmbedding.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts index 898e379f..355877e5 100644 --- a/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts +++ b/packages/components/nodes/embeddings/AzureOpenAIEmbedding/AzureOpenAIEmbedding.ts @@ -55,20 +55,6 @@ class AzureOpenAIEmbedding_Embeddings implements INode { ], default: '2023-03-15-preview' }, - { - label: 'Strip New Lines', - name: 'stripNewLines', - type: 'boolean', - optional: true, - additionalParams: true - }, - { - label: 'Batch Size', - name: 'batchSize', - type: 'number', - optional: true, - additionalParams: true - }, { label: 'Timeout', name: 'timeout', @@ -84,8 +70,6 @@ class AzureOpenAIEmbedding_Embeddings implements INode { const azureOpenAIApiInstanceName = nodeData.inputs?.azureOpenAIApiInstanceName as string const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string - const stripNewLines = nodeData.inputs?.stripNewLines as boolean - const batchSize = nodeData.inputs?.batchSize as string const timeout = nodeData.inputs?.timeout as string const obj: Partial & Partial = { @@ -95,8 +79,6 @@ class AzureOpenAIEmbedding_Embeddings implements INode { azureOpenAIApiVersion } - if (stripNewLines) obj.stripNewLines = stripNewLines - if (batchSize) obj.batchSize = parseInt(batchSize, 10) if (timeout) obj.timeout = parseInt(timeout, 10) const model = new OpenAIEmbeddings(obj) From 8805cd8e8fb5f4f7fa1e421fa0f9df59abfb861d Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 12 May 2023 21:02:13 +0700 Subject: [PATCH 15/15] remove unsupported params in AzureChatOpenAI & AzureOpenAI --- .../nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts | 9 --------- .../components/nodes/llms/Azure OpenAI/AzureOpenAI.ts | 9 --------- 2 files changed, 18 deletions(-) diff --git a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts index c4942d83..1d2fabc7 100644 --- a/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts @@ -86,13 +86,6 @@ class AzureChatOpenAI_ChatModels implements INode { optional: true, additionalParams: true }, - { - label: 'Top Probability', - name: 'topP', - type: 'number', - optional: true, - additionalParams: true - }, { label: 'Frequency Penalty', name: 'frequencyPenalty', @@ -125,7 +118,6 @@ class AzureChatOpenAI_ChatModels implements INode { const azureOpenAIApiDeploymentName = nodeData.inputs?.azureOpenAIApiDeploymentName as string const azureOpenAIApiVersion = nodeData.inputs?.azureOpenAIApiVersion as string const maxTokens = nodeData.inputs?.maxTokens as string - const topP = nodeData.inputs?.topP as string const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string const presencePenalty = nodeData.inputs?.presencePenalty as string const timeout = nodeData.inputs?.timeout as string @@ -140,7 +132,6 @@ class AzureChatOpenAI_ChatModels implements INode { } if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) if (timeout) obj.timeout = parseInt(timeout, 10) diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts index 47762cfd..b5d7d1e0 100644 --- a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -153,13 +153,6 @@ class AzureOpenAI_LLMs implements INode { optional: true, additionalParams: true }, - { - label: 'Batch Size', - name: 'batchSize', - type: 'number', - optional: true, - additionalParams: true - }, { label: 'Timeout', name: 'timeout', @@ -182,7 +175,6 @@ class AzureOpenAI_LLMs implements INode { const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string const presencePenalty = nodeData.inputs?.presencePenalty as string const timeout = nodeData.inputs?.timeout as string - const batchSize = nodeData.inputs?.batchSize as string const bestOf = nodeData.inputs?.bestOf as string const obj: Partial & Partial = { @@ -199,7 +191,6 @@ class AzureOpenAI_LLMs implements INode { if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) if (timeout) obj.timeout = parseInt(timeout, 10) - if (batchSize) obj.batchSize = parseInt(batchSize, 10) if (bestOf) obj.bestOf = parseInt(bestOf, 10) const model = new OpenAI(obj)