Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ class ChatOpenAI_ChatModels implements INode {
optional: true,
description: 'Default headers to include with every request to the API.',
additionalParams: true
},
{
label: 'Model Kwargs',
name: 'modelKwargs',
type: 'json',
optional: true,
description:
'Additional parameters to pass to the model body, e.g. {"parallel_tool_calls": false} or {"logit_bias": {50256: -100}}',
additionalParams: true
}
]
}
Expand Down Expand Up @@ -234,6 +243,7 @@ class ChatOpenAI_ChatModels implements INode {
const reasoningEffort = nodeData.inputs?.reasoningEffort as OpenAIClient.ReasoningEffort | null
const reasoningSummary = nodeData.inputs?.reasoningSummary as 'auto' | 'concise' | 'detailed' | null
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
const modelKwargs = nodeData.inputs?.modelKwargs

if (nodeData.inputs?.credentialId) {
nodeData.credential = nodeData.inputs?.credentialId
Expand Down Expand Up @@ -263,6 +273,15 @@ class ChatOpenAI_ChatModels implements INode {
}
if (strictToolCalling) obj.supportsStrictToolCalling = strictToolCalling

if (modelKwargs) {
try {
const parsedModelKwargs = typeof modelKwargs === 'object' ? modelKwargs : JSON.parse(modelKwargs)
obj.modelKwargs = parsedModelKwargs
} catch (exception) {
throw new Error("Invalid JSON in the ChatOpenAI's Model Kwargs: " + exception)
}
}

if (isReasoningModelOpenAI(modelName)) {
delete obj.temperature
delete obj.stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ class ChatOpenAICustom_ChatModels implements INode {
optional: true,
description: 'Default headers to include with every request to the API.',
additionalParams: true
},
{
label: 'Model Kwargs',
name: 'modelKwargs',
type: 'json',
optional: true,
description:
'Additional parameters to pass to the model body, e.g. {"parallel_tool_calls": false} or {"logit_bias": {50256: -100}}',
additionalParams: true
}
]
}
Expand All @@ -131,6 +140,7 @@ class ChatOpenAICustom_ChatModels implements INode {
const basePath = nodeData.inputs?.basepath as string
const baseOptions = nodeData.inputs?.baseOptions
const cache = nodeData.inputs?.cache as BaseCache
const modelKwargs = nodeData.inputs?.modelKwargs

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
Expand All @@ -150,6 +160,15 @@ class ChatOpenAICustom_ChatModels implements INode {
if (timeout) obj.timeout = parseInt(timeout, 10)
if (cache) obj.cache = cache

if (modelKwargs) {
try {
const parsedModelKwargs = typeof modelKwargs === 'object' ? modelKwargs : JSON.parse(modelKwargs)
obj.modelKwargs = parsedModelKwargs
} catch (exception) {
throw new Error("Invalid JSON in the ChatOpenAICustom's Model Kwargs: " + exception)
}
}

let parsedBaseOptions: any | undefined = undefined

if (baseOptions) {
Expand Down