Skip to content

Commit 097b3ec

Browse files
authored
fix: unkown characters in generation streaming (#293)
1 parent a2b2bc3 commit 097b3ec

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/evaluator/LlamaChat/LlamaChat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,7 @@ class GenerateResponseState<const Functions extends ChatModelFunctions | undefin
22152215
}
22162216

22172217
public waitOnPartialCharactersOrWhiteSpaceTokens() {
2218-
if (this.currentText === UNKNOWN_UNICODE_CHAR || (
2218+
if (this.currentText.endsWith(UNKNOWN_UNICODE_CHAR) || (
22192219
(this.grammar?.trimWhitespaceSuffix || this.trimWhitespaceSuffix) && this.currentText?.trim() === ""
22202220
)) {
22212221
if (this.currentQueuedTokenRelease != null)

src/evaluator/LlamaCompletion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ export class LlamaCompletion {
662662
const text = model.detokenize([token]);
663663
const queuedTokenRelease = streamRegulator.addChunk({tokens, text});
664664

665-
if (text === UNKNOWN_UNICODE_CHAR || (
665+
if (text.endsWith(UNKNOWN_UNICODE_CHAR) || (
666666
(grammar?.trimWhitespaceSuffix || trimWhitespaceSuffix) && text.trim() === ""
667667
)) {
668668
locksToReleaseOnValidGeneration.push(queuedTokenRelease.createTextIndexLock(0));

0 commit comments

Comments
 (0)