Refactor ChatOpenAI_ChatModels to include stopSequence parameter (#3388)
* Refactor ChatOpenAI_ChatModels to include stopSequence parameter * lint fix * Stop Sequence String will now be split by comma * Update ChatOpenAI.ts --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
parent
a0d93f910f
commit
35ce647a38
|
|
@ -111,6 +111,15 @@ class ChatOpenAI_ChatModels implements INode {
|
||||||
optional: true,
|
optional: true,
|
||||||
additionalParams: true
|
additionalParams: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Stop Sequence',
|
||||||
|
name: 'stopSequence',
|
||||||
|
type: 'string',
|
||||||
|
rows: 4,
|
||||||
|
optional: true,
|
||||||
|
description: 'List of stop words to use when generating. Use comma to separate multiple stop words.',
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'BaseOptions',
|
label: 'BaseOptions',
|
||||||
name: 'baseOptions',
|
name: 'baseOptions',
|
||||||
|
|
@ -168,6 +177,7 @@ class ChatOpenAI_ChatModels implements INode {
|
||||||
const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
|
const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
|
||||||
const presencePenalty = nodeData.inputs?.presencePenalty as string
|
const presencePenalty = nodeData.inputs?.presencePenalty as string
|
||||||
const timeout = nodeData.inputs?.timeout as string
|
const timeout = nodeData.inputs?.timeout as string
|
||||||
|
const stopSequence = nodeData.inputs?.stopSequence 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 proxyUrl = nodeData.inputs?.proxyUrl as string
|
const proxyUrl = nodeData.inputs?.proxyUrl as string
|
||||||
|
|
@ -199,6 +209,10 @@ 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)
|
||||||
if (cache) obj.cache = cache
|
if (cache) obj.cache = cache
|
||||||
|
if (stopSequence) {
|
||||||
|
const stopSequenceArray = stopSequence.split(',').map((item) => item.trim())
|
||||||
|
obj.stop = stopSequenceArray
|
||||||
|
}
|
||||||
|
|
||||||
let parsedBaseOptions: any | undefined = undefined
|
let parsedBaseOptions: any | undefined = undefined
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue