add chatOpenAI Finetuned

This commit is contained in:
Henry
2023-08-28 13:11:15 +01:00
parent 9e4bd71d8f
commit c25eaa1139
3 changed files with 169 additions and 1 deletions
@@ -125,6 +125,13 @@ class OpenAI_LLMs implements INode {
type: 'string',
optional: true,
additionalParams: true
},
{
label: 'BaseOptions',
name: 'baseOptions',
type: 'json',
optional: true,
additionalParams: true
}
]
}
@@ -141,6 +148,7 @@ class OpenAI_LLMs implements INode {
const bestOf = nodeData.inputs?.bestOf as string
const streaming = nodeData.inputs?.streaming as boolean
const basePath = nodeData.inputs?.basepath as string
const baseOptions = nodeData.inputs?.baseOptions
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
@@ -160,8 +168,19 @@ class OpenAI_LLMs implements INode {
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (bestOf) obj.bestOf = parseInt(bestOf, 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 OpenAI's BaseOptions: " + exception)
}
}
const model = new OpenAI(obj, {
basePath
basePath,
baseOptions: parsedBaseOptions
})
return model
}