From d46a8de64c2be36025e89eb6568778f0258d9ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D0=B5=D0=BA=20=D0=A7=D0=B0=D0=BD=D0=B3?= =?UTF-8?q?=D0=BB=D1=8F=D0=BD?= Date: Sun, 16 Nov 2025 22:53:55 +0300 Subject: [PATCH 1/3] feat: Add GigaChat (entities llm/embeddings/chatmodel/credential) --- .../credentials/GigaChat.credential.ts | 26 +++ .../chatmodels/ChatGigaChat/ChatGigaChat.ts | 162 ++++++++++++++++++ .../ChatGigaChat/FlowiseChatGigaChat.ts | 31 ++++ .../chatmodels/ChatGigaChat/GigaChat.svg | 39 +++++ .../embeddings/GigaChatEmbedding/GigaChat.svg | 39 +++++ .../GigaChatEmbedding/GigaChatEmbedding.ts | 126 ++++++++++++++ .../nodes/llms/GigaChat/GigaChat.svg | 39 +++++ .../nodes/llms/GigaChat/GigaChat.ts | 161 +++++++++++++++++ packages/components/package.json | 1 + .../components/utilities/https-agent.util.ts | 6 + packages/server/.env.example | 3 + 11 files changed, 633 insertions(+) create mode 100644 packages/components/credentials/GigaChat.credential.ts create mode 100644 packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts create mode 100644 packages/components/nodes/chatmodels/ChatGigaChat/FlowiseChatGigaChat.ts create mode 100644 packages/components/nodes/chatmodels/ChatGigaChat/GigaChat.svg create mode 100644 packages/components/nodes/embeddings/GigaChatEmbedding/GigaChat.svg create mode 100644 packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts create mode 100644 packages/components/nodes/llms/GigaChat/GigaChat.svg create mode 100644 packages/components/nodes/llms/GigaChat/GigaChat.ts create mode 100644 packages/components/utilities/https-agent.util.ts diff --git a/packages/components/credentials/GigaChat.credential.ts b/packages/components/credentials/GigaChat.credential.ts new file mode 100644 index 00000000000..ae6d758158a --- /dev/null +++ b/packages/components/credentials/GigaChat.credential.ts @@ -0,0 +1,26 @@ +import { INodeCredential, INodeParams } from "../src/Interface" + +class GigaChatApi implements INodeCredential { + label: string + name: string + version: number + description: string + inputs: INodeParams[] + + constructor() { + this.label = 'GigaChat API' + this.name = 'gigaChatApi' + this.version = 1.0 + this.description = 'Получить Credentials токен от GigaChatApi можно в Личном кабините' + this.inputs = [ + { + label: 'Access Token', + name: 'accessToken', + type: 'password', + placeholder: '' + } + ] + } +} + +module.exports = { credClass: GigaChatApi } \ No newline at end of file diff --git a/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts b/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts new file mode 100644 index 00000000000..1e815096dad --- /dev/null +++ b/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts @@ -0,0 +1,162 @@ +import { GigaChat as GigaChatLangchain } from 'langchain-gigachat' +import { FlowiseGigaChat } from './FlowiseChatGigaChat' + +import { httpsAgent } from '../../../utilities/https-agent.util' +import { getBaseClasses, getCredentialData } from '../../../src/utils' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' + +class ChatGigaChat implements INode { + label: string + name: string + version: number + type: string + icon: string + category: string + description: string + baseClasses: string[] + credential: INodeParams + inputs: INodeParams[] + + constructor() { + this.label = 'ChatGigaChat' + this.name = 'chatgigachat' + this.version = 2.0 + this.type = 'ChatGigaChat' + this.icon = 'GigaChat.svg' + this.category = 'Chat Models' + this.description = 'Wrapper around GigaChat large language models that use the Chat endpoint' + this.baseClasses = [this.type, ...getBaseClasses(GigaChatLangchain)] + this.credential = { + label: 'Credential', + name: 'credential', + type: 'credential', + credentialNames: ['gigaChatApi'] + } + this.inputs = [ + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'GigaChat v2', + name: 'GigaChat-2', + description: 'The most advanced model' + }, + { + label: 'GigaChat Pro v2', + name: 'GigaChat-2-Pro', + description: 'The most advanced model Pro' + }, + { + label: 'GigaChat Max v2', + name: 'GigaChat-2-Max', + description: 'The most advanced model Max' + }, + { + label: 'GigaChat Max', + name: 'GigaChat-Max', + description: 'An advanced model for complex tasks that require a high level of creativity and quality of work' + }, + { + label: 'GigaChat Pro', + name: 'GigaChat-Pro', + description: + 'the model follows complex instructions more effectively and can handle more sophisticated tasks: the quality of summarization, rewriting and editing texts, and answering various questions has improved significantly' + }, + { + label: 'GigaChat Plus', + name: 'GigaChat-Plus', + description: + 'Ideally suited for tasks that require sending a large amount of information in a single request.' + }, + { + label: 'GigaChat', + name: 'GigaChat', + description: + 'Suitable for solving simpler tasks that require maximum processing speed. At the same time, the cost of using the model is lower because it requires fewer computational resources.' + } + ], + default: 'GigaChat-2-Pro' + }, + { + label: 'Scope', + name: 'scope', + type: 'options', + description: 'a required field in the request body that specifies which API version the request is being made to', + options: [ + { + label: 'GIGACHAT_API_PERS', + name: 'GIGACHAT_API_PERS', + description: 'access for individuals' + }, + { + label: 'GIGACHAT_API_B2B', + name: 'GIGACHAT_API_B2B', + description: 'access for sole proprietors and legal entities through paid packages' + }, + { + label: 'GIGACHAT_API_CORP', + name: 'GIGACHAT_API_CORP', + description: 'access for sole proprietors and legal entities on a pay-as-you-go basis”**' + } + ], + default: 'GIGACHAT_API_PERS' + }, + { + label: 'Base URL', + name: 'baseUrl', + type: 'string', + default: 'https://gigachat.devices.sberbank.ru/api/v1/', + description: 'API URL', + optional: false + }, + { + label: 'Temperature', + name: 'temperature', + type: 'number', + step: 0.1, + default: 1, + optional: true + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', + step: 1, + default: 60000, + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const temperature = Number(nodeData.inputs?.temperature || 1) + const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') + const modelName = nodeData.inputs?.modelName as string + const timeout = Number(nodeData.inputs?.timeout || 60000) + const baseUrl = String(nodeData.inputs?.baseUrl || '') + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const credentials = credentialData?.accessToken + + const params: any = { + credentials, + model: modelName, + scope, + httpsAgent, + profanityCheck: false, + timeout, + verbose: false, + streaming: true, + temperature, + baseUrl + } + + const model = new FlowiseGigaChat(params.model, params) + + return model + } +} + +module.exports = { nodeClass: ChatGigaChat } \ No newline at end of file diff --git a/packages/components/nodes/chatmodels/ChatGigaChat/FlowiseChatGigaChat.ts b/packages/components/nodes/chatmodels/ChatGigaChat/FlowiseChatGigaChat.ts new file mode 100644 index 00000000000..0b42613948f --- /dev/null +++ b/packages/components/nodes/chatmodels/ChatGigaChat/FlowiseChatGigaChat.ts @@ -0,0 +1,31 @@ +import { ChatOpenAIFields } from '@langchain/openai' +import { GigaChat as LangchainGigaChat } from 'langchain-gigachat' + +import { IMultiModalOption, IVisionChatModal } from '../../../src' + +export class FlowiseGigaChat extends LangchainGigaChat implements IVisionChatModal { + configuredModel: string + configuredMaxToken?: number + multiModalOption: IMultiModalOption + id: string + + constructor(id: string, fields?: ChatOpenAIFields) { + super(fields) + this.id = id + this.configuredModel = fields?.modelName ?? '' + this.configuredMaxToken = fields?.maxTokens + } + + revertToOriginalModel(): void { + this.model = this.configuredModel + this.maxTokens = this.configuredMaxToken + } + + setMultiModalOption(multiModalOption: IMultiModalOption): void { + this.multiModalOption = multiModalOption + } + + setVisionModel(): void { + // pass + } +} \ No newline at end of file diff --git a/packages/components/nodes/chatmodels/ChatGigaChat/GigaChat.svg b/packages/components/nodes/chatmodels/ChatGigaChat/GigaChat.svg new file mode 100644 index 00000000000..70a4a290d4c --- /dev/null +++ b/packages/components/nodes/chatmodels/ChatGigaChat/GigaChat.svg @@ -0,0 +1,39 @@ + + + + + + + + + diff --git a/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChat.svg b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChat.svg new file mode 100644 index 00000000000..70a4a290d4c --- /dev/null +++ b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChat.svg @@ -0,0 +1,39 @@ + + + + + + + + + diff --git a/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts new file mode 100644 index 00000000000..73d3cd495e0 --- /dev/null +++ b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts @@ -0,0 +1,126 @@ +import { GigaChatEmbeddings as GCEmbeddings } from 'langchain-gigachat' + +import { httpsAgent } from '../../../utilities/https-agent.util' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData } from '../../../src/utils' + +class GigaChatEmbedding implements INode { + label: string + name: string + version: number + type: string + icon: string + category: string + description: string + baseClasses: string[] + credential: INodeParams + inputs: INodeParams[] + + constructor() { + this.label = 'GigaChatEmbedding' + this.name = 'gigachatembedding' + this.version = 2.0 + this.type = 'ChatGigaEmbedding' + this.icon = 'GigaChat.svg' + this.category = 'Embeddings' + this.description = 'Wrapper around GigaChat large language models' + this.baseClasses = [this.type, 'BaseEmbedding_LlamaIndex', ...getBaseClasses(GCEmbeddings)] + this.credential = { + label: 'Credential', + name: 'credential', + type: 'credential', + credentialNames: ['gigaChatApi'] + } + this.inputs = [ + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'Embeddings', + name: 'Embeddings', + description: 'basic model, available by default for vector representation of texts' + }, + { + label: 'Embeddings 2', + name: 'Embeddings-2', + description: 'an improved model with better quality embeddings' + }, + { + label: 'EmbeddingsGigaR', + name: 'EmbeddingsGigaR', + description: 'an advanced model with a large context' + } + ], + default: 'Embeddings' + }, + { + label: 'Scope', + name: 'scope', + type: 'options', + description: 'a required field in the request body that indicates which API version the request is being made to', + options: [ + { + label: 'GIGACHAT_API_PERS', + name: 'GIGACHAT_API_PERS', + description: 'personal access for individuals' + }, + { + label: 'GIGACHAT_API_B2B', + name: 'GIGACHAT_API_B2B', + description: 'business access for self-employed individuals' + }, + { + label: 'GIGACHAT_API_CORP', + name: 'GIGACHAT_API_CORP', + description: 'for corporate clients pay-as-you-go' + } + ], + default: 'GIGACHAT_API_PERS' + }, + { + label: 'Base URL', + name: 'baseUrl', + type: 'string', + default:'https://gigachat.devices.sberbank.ru/api/v1/', + description: 'API URL', + optional: false + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', + step: 1, + default: 60000, + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const timeout = Number(nodeData.inputs?.timeout || 60000) + const baseUrl = String(nodeData.inputs?.baseUrl || '') + const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') + const modelName = nodeData.inputs?.modelName as string + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const credentials = credentialData?.accessToken + + const params: any = { + credentials, + scope, + httpsAgent, + timeout, + verbose: false, + baseUrl, + model: modelName + } + + const model = new GCEmbeddings(params) + + return model + } +} + +module.exports = { nodeClass: GigaChatEmbedding } \ No newline at end of file diff --git a/packages/components/nodes/llms/GigaChat/GigaChat.svg b/packages/components/nodes/llms/GigaChat/GigaChat.svg new file mode 100644 index 00000000000..70a4a290d4c --- /dev/null +++ b/packages/components/nodes/llms/GigaChat/GigaChat.svg @@ -0,0 +1,39 @@ + + + + + + + + + diff --git a/packages/components/nodes/llms/GigaChat/GigaChat.ts b/packages/components/nodes/llms/GigaChat/GigaChat.ts new file mode 100644 index 00000000000..2760bff5c0a --- /dev/null +++ b/packages/components/nodes/llms/GigaChat/GigaChat.ts @@ -0,0 +1,161 @@ +import { GigaChat as GigaChatInstance } from 'langchain-gigachat' + +import { httpsAgent } from '../../../utilities/https-agent.util' +import { getBaseClasses, getCredentialData } from '../../../src/utils' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' + +class GigaChat implements INode { + label: string + name: string + version: number + type: string + icon: string + category: string + description: string + baseClasses: string[] + credential: INodeParams + inputs: INodeParams[] + + constructor() { + this.label = 'GigaChat' + this.name = 'gigachat' + this.version = 2.0 + this.type = 'GigaChat' + this.icon = 'GigaChat.svg' + this.category = 'LLMs' + this.description = 'Wrapper around GigaChat large language models' + this.baseClasses = [this.type, ...getBaseClasses(GigaChatInstance)] + this.credential = { + label: 'Credential', + name: 'credential', + type: 'credential', + credentialNames: ['gigaChatApi'], + } + this.inputs = [ + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + label: 'GigaChat v2', + name: 'GigaChat-2', + description: 'The most advanced model' + }, + { + label: 'GigaChat Pro v2', + name: 'GigaChat-2-Pro', + description: 'The most advanced model Pro' + }, + { + label: 'GigaChat Max v2', + name: 'GigaChat-2-Max', + description: 'The most advanced model Max' + }, + { + label: 'GigaChat Max', + name: 'GigaChat-Max', + description: 'An advanced model for complex tasks that require a high level of creativity and quality of work' + }, + { + label: 'GigaChat Pro', + name: 'GigaChat-Pro', + description: + 'the model follows complex instructions more effectively and can handle more sophisticated tasks: the quality of summarization, rewriting and editing texts, and answering various questions has improved significantly' + }, + { + label: 'GigaChat Plus', + name: 'GigaChat-Plus', + description: + 'Ideally suited for tasks that require sending a large amount of information in a single request.' + }, + { + label: 'GigaChat', + name: 'GigaChat', + description: + 'Suitable for solving simpler tasks that require maximum processing speed. At the same time, the cost of using the model is lower because it requires fewer computational resources.' + } + ], + default: 'GigaChat-2-Pro' + }, + { + label: 'Scope', + name: 'scope', + type: 'options', + description: 'a required field in the request body that specifies which API version the request is being made to', + options: [ + { + label: 'GIGACHAT_API_PERS', + name: 'GIGACHAT_API_PERS', + description: 'access for individuals' + }, + { + label: 'GIGACHAT_API_B2B', + name: 'GIGACHAT_API_B2B', + description: 'access for sole proprietors and legal entities through paid packages' + }, + { + label: 'GIGACHAT_API_CORP', + name: 'GIGACHAT_API_CORP', + description: 'access for sole proprietors and legal entities on a pay-as-you-go basis”**' + } + ], + default: 'GIGACHAT_API_PERS' + }, + { + label: 'Base URL', + name: 'baseUrl', + type: 'string', + default: 'https://gigachat.devices.sberbank.ru/api/v1/', + description: 'API URL', + optional: false + }, + { + label: 'Temperature', + name: 'temperature', + type: 'number', + step: 0.1, + default: 1, + optional: true + }, + { + label: 'Timeout', + name: 'timeout', + type: 'number', + step: 1, + default: 60000, + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const temperature = Number(nodeData.inputs?.temperature || 1) + const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') + const modelName = nodeData.inputs?.modelName as string + const timeout = Number(nodeData.inputs?.timeout || 60000) + const baseUrl = String(nodeData.inputs?.baseUrl || '') + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const credentials = credentialData?.accessToken + + const params: any = { + credentials, + model: modelName, + scope, + httpsAgent, + profanityCheck: false, + timeout, + verbose: false, + streaming: true, + temperature, + baseUrl + } + + const model = new GigaChatInstance(params) + + return model + } +} + +module.exports = { nodeClass: GigaChat } \ No newline at end of file diff --git a/packages/components/package.json b/packages/components/package.json index f3894f996c4..92d20a533a8 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -110,6 +110,7 @@ "jsonpointer": "^5.0.1", "jsonrepair": "^3.11.1", "langchain": "^0.3.5", + "langchain-gigachat": "^0.0.14", "langfuse": "3.3.4", "langfuse-langchain": "^3.3.4", "langsmith": "0.1.6", diff --git a/packages/components/utilities/https-agent.util.ts b/packages/components/utilities/https-agent.util.ts new file mode 100644 index 00000000000..370d38f6a50 --- /dev/null +++ b/packages/components/utilities/https-agent.util.ts @@ -0,0 +1,6 @@ +import https from 'node:https' + +export const httpsAgent = new https.Agent({ + rejectUnauthorized: false, + requestCert: false +}) diff --git a/packages/server/.env.example b/packages/server/.env.example index 282e4cd33fc..69d2eaef125 100644 --- a/packages/server/.env.example +++ b/packages/server/.env.example @@ -186,3 +186,6 @@ JWT_REFRESH_TOKEN_EXPIRY_IN_MINUTES=43200 # PUPPETEER_EXECUTABLE_FILE_PATH='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' # PLAYWRIGHT_EXECUTABLE_FILE_PATH='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' + +# To use GigaChat, you need to allow self-signed certificates +# NODE_TLS_REJECT_UNAUTHORIZED=0 \ No newline at end of file From b54ca3b4fc855d5cd46fdba75f54acb5a3a9497e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D0=B5=D0=BA=20=D0=A7=D0=B0=D0=BD=D0=B3?= =?UTF-8?q?=D0=BB=D1=8F=D0=BD?= Date: Sun, 16 Nov 2025 22:57:13 +0300 Subject: [PATCH 2/3] bugfix: add translates to GigaChat Credential --- packages/components/credentials/GigaChat.credential.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/credentials/GigaChat.credential.ts b/packages/components/credentials/GigaChat.credential.ts index ae6d758158a..73e2e446173 100644 --- a/packages/components/credentials/GigaChat.credential.ts +++ b/packages/components/credentials/GigaChat.credential.ts @@ -11,7 +11,7 @@ class GigaChatApi implements INodeCredential { this.label = 'GigaChat API' this.name = 'gigaChatApi' this.version = 1.0 - this.description = 'Получить Credentials токен от GigaChatApi можно в Личном кабините' + this.description = 'You can get the Credentials token from GigaChatApi in Developer Console' this.inputs = [ { label: 'Access Token', From 7b770c5f64e65571c078c28cdf43bbc69f930254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D0=B5=D0=BA=20=D0=A7=D0=B0=D0=BD=D0=B3?= =?UTF-8?q?=D0=BB=D1=8F=D0=BD?= Date: Mon, 17 Nov 2025 22:41:38 +0300 Subject: [PATCH 3/3] bugfix: corrected errors in texts and removed the httpsAgent utility --- .../credentials/GigaChat.credential.ts | 2 +- .../chatmodels/ChatGigaChat/ChatGigaChat.ts | 10 +++++----- .../GigaChatEmbedding/GigaChatEmbedding.ts | 11 ++++++----- .../components/nodes/llms/GigaChat/GigaChat.ts | 17 ++++++++--------- .../components/utilities/https-agent.util.ts | 6 ------ 5 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 packages/components/utilities/https-agent.util.ts diff --git a/packages/components/credentials/GigaChat.credential.ts b/packages/components/credentials/GigaChat.credential.ts index 73e2e446173..745a6343e72 100644 --- a/packages/components/credentials/GigaChat.credential.ts +++ b/packages/components/credentials/GigaChat.credential.ts @@ -11,7 +11,7 @@ class GigaChatApi implements INodeCredential { this.label = 'GigaChat API' this.name = 'gigaChatApi' this.version = 1.0 - this.description = 'You can get the Credentials token from GigaChatApi in Developer Console' + this.description = 'You can get the Credentials token from GigaChat API in Developer Console' this.inputs = [ { label: 'Access Token', diff --git a/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts b/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts index 1e815096dad..2a3e0584be8 100644 --- a/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts +++ b/packages/components/nodes/chatmodels/ChatGigaChat/ChatGigaChat.ts @@ -1,10 +1,11 @@ import { GigaChat as GigaChatLangchain } from 'langchain-gigachat' import { FlowiseGigaChat } from './FlowiseChatGigaChat' -import { httpsAgent } from '../../../utilities/https-agent.util' import { getBaseClasses, getCredentialData } from '../../../src/utils' import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +const defaultBaseUrl = 'https://gigachat.devices.sberbank.ru/api/v1/' + class ChatGigaChat implements INode { label: string name: string @@ -98,7 +99,7 @@ class ChatGigaChat implements INode { { label: 'GIGACHAT_API_CORP', name: 'GIGACHAT_API_CORP', - description: 'access for sole proprietors and legal entities on a pay-as-you-go basis”**' + description: 'access for sole proprietors and legal entities on a pay-as-you-go basis' } ], default: 'GIGACHAT_API_PERS' @@ -107,7 +108,7 @@ class ChatGigaChat implements INode { label: 'Base URL', name: 'baseUrl', type: 'string', - default: 'https://gigachat.devices.sberbank.ru/api/v1/', + default: defaultBaseUrl, description: 'API URL', optional: false }, @@ -135,7 +136,7 @@ class ChatGigaChat implements INode { const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') const modelName = nodeData.inputs?.modelName as string const timeout = Number(nodeData.inputs?.timeout || 60000) - const baseUrl = String(nodeData.inputs?.baseUrl || '') + const baseUrl = String(nodeData.inputs?.baseUrl || defaultBaseUrl) const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentials = credentialData?.accessToken @@ -144,7 +145,6 @@ class ChatGigaChat implements INode { credentials, model: modelName, scope, - httpsAgent, profanityCheck: false, timeout, verbose: false, diff --git a/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts index 73d3cd495e0..d8e7758967a 100644 --- a/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts +++ b/packages/components/nodes/embeddings/GigaChatEmbedding/GigaChatEmbedding.ts @@ -1,9 +1,11 @@ +import https from 'node:https' import { GigaChatEmbeddings as GCEmbeddings } from 'langchain-gigachat' -import { httpsAgent } from '../../../utilities/https-agent.util' + import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' import { getBaseClasses, getCredentialData } from '../../../src/utils' +const defaultBaseUrl = 'https://gigachat.devices.sberbank.ru/api/v1/' class GigaChatEmbedding implements INode { label: string name: string @@ -20,7 +22,7 @@ class GigaChatEmbedding implements INode { this.label = 'GigaChatEmbedding' this.name = 'gigachatembedding' this.version = 2.0 - this.type = 'ChatGigaEmbedding' + this.type = 'GigaChatEmbedding' this.icon = 'GigaChat.svg' this.category = 'Embeddings' this.description = 'Wrapper around GigaChat large language models' @@ -83,7 +85,7 @@ class GigaChatEmbedding implements INode { label: 'Base URL', name: 'baseUrl', type: 'string', - default:'https://gigachat.devices.sberbank.ru/api/v1/', + default:defaultBaseUrl, description: 'API URL', optional: false }, @@ -100,7 +102,7 @@ class GigaChatEmbedding implements INode { async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { const timeout = Number(nodeData.inputs?.timeout || 60000) - const baseUrl = String(nodeData.inputs?.baseUrl || '') + const baseUrl = String(nodeData.inputs?.baseUrl || defaultBaseUrl) const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') const modelName = nodeData.inputs?.modelName as string @@ -110,7 +112,6 @@ class GigaChatEmbedding implements INode { const params: any = { credentials, scope, - httpsAgent, timeout, verbose: false, baseUrl, diff --git a/packages/components/nodes/llms/GigaChat/GigaChat.ts b/packages/components/nodes/llms/GigaChat/GigaChat.ts index 2760bff5c0a..266f55c0390 100644 --- a/packages/components/nodes/llms/GigaChat/GigaChat.ts +++ b/packages/components/nodes/llms/GigaChat/GigaChat.ts @@ -1,9 +1,10 @@ import { GigaChat as GigaChatInstance } from 'langchain-gigachat' -import { httpsAgent } from '../../../utilities/https-agent.util' import { getBaseClasses, getCredentialData } from '../../../src/utils' import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +const defaultBaseUrl = 'https://gigachat.devices.sberbank.ru/api/v1/' + class GigaChat implements INode { label: string name: string @@ -29,7 +30,7 @@ class GigaChat implements INode { label: 'Credential', name: 'credential', type: 'credential', - credentialNames: ['gigaChatApi'], + credentialNames: ['gigaChatApi'] } this.inputs = [ { @@ -66,8 +67,7 @@ class GigaChat implements INode { { label: 'GigaChat Plus', name: 'GigaChat-Plus', - description: - 'Ideally suited for tasks that require sending a large amount of information in a single request.' + description: 'Ideally suited for tasks that require sending a large amount of information in a single request.' }, { label: 'GigaChat', @@ -97,7 +97,7 @@ class GigaChat implements INode { { label: 'GIGACHAT_API_CORP', name: 'GIGACHAT_API_CORP', - description: 'access for sole proprietors and legal entities on a pay-as-you-go basis”**' + description: 'access for sole proprietors and legal entities on a pay-as-you-go basis' } ], default: 'GIGACHAT_API_PERS' @@ -106,7 +106,7 @@ class GigaChat implements INode { label: 'Base URL', name: 'baseUrl', type: 'string', - default: 'https://gigachat.devices.sberbank.ru/api/v1/', + default: defaultBaseUrl, description: 'API URL', optional: false }, @@ -134,7 +134,7 @@ class GigaChat implements INode { const scope = String(nodeData.inputs?.scope || 'GIGACHAT_API_PERS') const modelName = nodeData.inputs?.modelName as string const timeout = Number(nodeData.inputs?.timeout || 60000) - const baseUrl = String(nodeData.inputs?.baseUrl || '') + const baseUrl = String(nodeData.inputs?.baseUrl || defaultBaseUrl) const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentials = credentialData?.accessToken @@ -143,7 +143,6 @@ class GigaChat implements INode { credentials, model: modelName, scope, - httpsAgent, profanityCheck: false, timeout, verbose: false, @@ -158,4 +157,4 @@ class GigaChat implements INode { } } -module.exports = { nodeClass: GigaChat } \ No newline at end of file +module.exports = { nodeClass: GigaChat } diff --git a/packages/components/utilities/https-agent.util.ts b/packages/components/utilities/https-agent.util.ts deleted file mode 100644 index 370d38f6a50..00000000000 --- a/packages/components/utilities/https-agent.util.ts +++ /dev/null @@ -1,6 +0,0 @@ -import https from 'node:https' - -export const httpsAgent = new https.Agent({ - rejectUnauthorized: false, - requestCert: false -})