Skip to content

Commit a09414a

Browse files
fix(client): use a different faux token because the other ones still caused issues
1 parent 2e0f951 commit a09414a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/ChatGPTClient.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export default class ChatGPTClient {
5252
// Use these faux tokens to help the AI understand the context since we are building the chat log ourselves.
5353
// Trying to use "<|im_start|>" causes the AI to still generate "<" or "<|" at the end sometimes for some reason,
5454
// without tripping the stop sequences, so I'm using "##im_start##" instead.
55-
this.startToken = 'im_start##';
56-
this.endToken = '##im_end';
55+
this.startToken = '||>';
56+
this.endToken = '';
5757
} else if (isUnofficialChatGptModel) {
5858
this.startToken = '<|im_start|>';
5959
this.endToken = '<|im_end|>';
@@ -68,13 +68,13 @@ export default class ChatGPTClient {
6868
}
6969

7070
if (!this.modelOptions.stop) {
71-
if (this.startToken !== this.endToken) {
72-
this.modelOptions.stop = [this.endToken, this.startToken];
73-
} else {
74-
this.modelOptions.stop = [this.endToken];
71+
const stopTokens = [this.startToken];
72+
if (this.endToken && this.endToken !== this.startToken) {
73+
stopTokens.push(this.endToken);
7574
}
76-
this.modelOptions.stop.push(`\n${this.userLabel}:`);
75+
stopTokens.push(`\n${this.userLabel}:`);
7776
// I chose not to do one for `chatGptLabel` because I've never seen it happen
77+
this.modelOptions.stop = stopTokens;
7878
}
7979

8080
if (this.options.reverseProxyUrl) {

0 commit comments

Comments
 (0)