mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Merge pull request #787 from raffareis/feature/ChatOpenAIBaseOption
Added BaseOptions to ChatOpenAI
This commit is contained in:
@@ -125,6 +125,13 @@ class ChatOpenAI_ChatModels implements INode {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
optional: true,
|
optional: true,
|
||||||
additionalParams: true
|
additionalParams: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'BaseOptions',
|
||||||
|
name: 'baseOptions',
|
||||||
|
type: 'json',
|
||||||
|
optional: true,
|
||||||
|
additionalParams: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -139,6 +146,7 @@ class ChatOpenAI_ChatModels implements INode {
|
|||||||
const timeout = nodeData.inputs?.timeout as string
|
const timeout = nodeData.inputs?.timeout as string
|
||||||
const streaming = nodeData.inputs?.streaming as boolean
|
const streaming = nodeData.inputs?.streaming as boolean
|
||||||
const basePath = nodeData.inputs?.basepath as string
|
const basePath = nodeData.inputs?.basepath as string
|
||||||
|
const baseOptions = nodeData.inputs?.baseOptions
|
||||||
|
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
|
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
|
||||||
@@ -156,8 +164,18 @@ class ChatOpenAI_ChatModels implements INode {
|
|||||||
if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)
|
if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)
|
||||||
if (timeout) obj.timeout = parseInt(timeout, 10)
|
if (timeout) obj.timeout = parseInt(timeout, 10)
|
||||||
|
|
||||||
|
let parsedBaseOptions: any | undefined = undefined
|
||||||
|
|
||||||
|
if (baseOptions) {
|
||||||
|
try {
|
||||||
|
parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
|
||||||
|
} catch (exception) {
|
||||||
|
throw new Error("Invalid JSON in the ChatOpenAI's BaseOptions: " + exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
const model = new ChatOpenAI(obj, {
|
const model = new ChatOpenAI(obj, {
|
||||||
basePath
|
basePath,
|
||||||
|
baseOptions: parsedBaseOptions
|
||||||
})
|
})
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user