File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments