Skip to content

Commit

Permalink
chore: moving from im_end to completion params
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Cadienvan authored Feb 4, 2023
1 parent d8072bb commit 329e076
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/chatgpt-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 329e076

Please sign in to comment.