Skip to content

Commit

Permalink
Add chat model open ai proxy url params (#3153)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
thanhtung100397 and HenryHengZJ committed Sep 9, 2024
1 parent 4747934 commit 40a1064
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 40a1064

Please sign in to comment.