Skip to content

Commit

Permalink
fix: unkown characters in generation streaming (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
giladgd authored Aug 7, 2024
1 parent a2b2bc3 commit 097b3ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/evaluator/LlamaChat/LlamaChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ class GenerateResponseState<const Functions extends ChatModelFunctions | undefin
}

public waitOnPartialCharactersOrWhiteSpaceTokens() {
if (this.currentText === UNKNOWN_UNICODE_CHAR || (
if (this.currentText.endsWith(UNKNOWN_UNICODE_CHAR) || (
(this.grammar?.trimWhitespaceSuffix || this.trimWhitespaceSuffix) && this.currentText?.trim() === ""
)) {
if (this.currentQueuedTokenRelease != null)
Expand Down
2 changes: 1 addition & 1 deletion src/evaluator/LlamaCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export class LlamaCompletion {
const text = model.detokenize([token]);
const queuedTokenRelease = streamRegulator.addChunk({tokens, text});

if (text === UNKNOWN_UNICODE_CHAR || (
if (text.endsWith(UNKNOWN_UNICODE_CHAR) || (
(grammar?.trimWhitespaceSuffix || trimWhitespaceSuffix) && text.trim() === ""
)) {
locksToReleaseOnValidGeneration.push(queuedTokenRelease.createTextIndexLock(0));
Expand Down

0 comments on commit 097b3ec

Please sign in to comment.