Skip to content

Commit 4a180f8

Browse files
committed
fix: bugs
1 parent d9f133a commit 4a180f8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/evaluator/LlamaChat/LlamaChat.ts

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

17311731
public getPenaltyTokens() {
17321732
if (this.llamaChat.disposed)
1733-
throw new DisposedError();
1733+
return [];
17341734

17351735
let punishTokens = this.res.slice(-this.resolvedRepeatPenalty.lastTokens);
17361736

src/evaluator/LlamaChatSession/LlamaChatSession.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ export class LlamaChatSession {
647647
.filter((result): result is Exclude<typeof result, null> => result != null);
648648
this._ensureNotDisposed();
649649

650-
if (abortController.signal.aborted)
650+
if (abortController.signal.aborted && (abortedOnFunctionCallError || !stopOnAbortSignal))
651651
throw abortController.signal.reason;
652652

653653
newContextWindowChatHistory = lastEvaluation.contextWindow;
@@ -680,7 +680,11 @@ export class LlamaChatSession {
680680
lastEvaluation.cleanHistory = newChatHistory;
681681
lastEvaluation.contextWindow = newContextWindowChatHistory;
682682

683-
continue;
683+
if (abortController.signal.aborted && !abortedOnFunctionCallError && stopOnAbortSignal) {
684+
metadata.stopReason = "abort";
685+
metadata.remainingGenerationAfterStop = undefined;
686+
} else
687+
continue;
684688
}
685689
}
686690

0 commit comments

Comments
 (0)