chore: moving from im_end to completion params

As we allow the constructor to define completionParams, it would be better to allow devs using the library to use the specified stop token.
As of right now, the library allows such stop to be passed but it isn't considered in the class itself.
chatgpt-api
Michael Di Prisco 2023-02-04 09:44:51 +01:00 zatwierdzone przez GitHub
rodzic aaff786b30
commit 78b376d189
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -307,7 +307,7 @@ Current date: ${currentDate}\n\n`
const maxNumTokens = this._maxModelTokens - this._maxResponseTokens
let { parentMessageId } = opts
let nextPromptBody = `${this._userLabel}:\n\n${message}<|im_end|>`
let nextPromptBody = `${this._userLabel}:\n\n${message}${this._completionParams.stop}`
let promptBody = ''
let prompt: string
let numTokens: number
@ -343,7 +343,7 @@ Current date: ${currentDate}\n\n`
parentMessageRole === 'user' ? this._userLabel : this._assistantLabel
// TODO: differentiate between assistant and user messages
const parentMessageString = `${parentMessageRoleDesc}:\n\n${parentMessage.text}<|im_end|>\n\n`
const parentMessageString = `${parentMessageRoleDesc}:\n\n${parentMessage.text}${this._completionParams.stop}\n\n`
nextPromptBody = `${parentMessageString}${promptBody}`
parentMessageId = parentMessage.parentMessageId
} while (true)