From 40a1064a8f13e995e0e94df5d0b246e423a23519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20Thanh=20T=C3=B9ng?= Date: Tue, 10 Sep 2024 05:10:39 +0700 Subject: [PATCH] Add chat model open ai proxy url params (#3153) * Add chat model open api proxy url param * Refactor add proxy url to chat model open ai * Update ChatOpenAI.ts --------- Co-authored-by: Henry Heng --- .../nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts b/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts index 532b8d5b1fc..5f3e1542904 100644 --- a/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts @@ -6,6 +6,7 @@ import { ICommonObject, IMultiModalOption, INode, INodeData, INodeOptionsValue, import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' import { ChatOpenAI } from './FlowiseChatOpenAI' import { getModels, MODEL_TYPE } from '../../../src/modelLoader' +import { HttpsProxyAgent } from 'https-proxy-agent' class ChatOpenAI_ChatModels implements INode { label: string @@ -22,7 +23,7 @@ class ChatOpenAI_ChatModels implements INode { constructor() { this.label = 'ChatOpenAI' this.name = 'chatOpenAI' - this.version = 6.0 + this.version = 7.0 this.type = 'ChatOpenAI' this.icon = 'openai.svg' this.category = 'Chat Models' @@ -103,6 +104,13 @@ class ChatOpenAI_ChatModels implements INode { optional: true, additionalParams: true }, + { + label: 'Proxy Url', + name: 'proxyUrl', + type: 'string', + optional: true, + additionalParams: true + }, { label: 'BaseOptions', name: 'baseOptions', @@ -162,6 +170,7 @@ class ChatOpenAI_ChatModels implements INode { const timeout = nodeData.inputs?.timeout as string const streaming = nodeData.inputs?.streaming as boolean const basePath = nodeData.inputs?.basepath as string + const proxyUrl = nodeData.inputs?.proxyUrl as string const baseOptions = nodeData.inputs?.baseOptions const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean @@ -208,6 +217,13 @@ class ChatOpenAI_ChatModels implements INode { } } + if (proxyUrl) { + obj.configuration = { + ...obj?.configuration, + httpAgent: new HttpsProxyAgent(proxyUrl) + } + } + const multiModalOption: IMultiModalOption = { image: { allowImageUploads: allowImageUploads ?? false,