File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ export async function getLlamaGpuTypes(include: "supported" | "allValid"): Promi
1818 const platform = getPlatform ( ) ;
1919 const arch = process . arch ;
2020
21+ if ( include == null )
22+ include = "supported" ;
23+
2124 if ( include === "supported" ) {
2225 const gpuTypes = new Set ( await getGpuTypesToUseForOption ( "auto" ) ) ;
2326
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import {LlamaModel} from "../LlamaModel/LlamaModel.js";
2626import { getChatWrapperSegmentDefinition } from "../../utils/getChatWrapperSegmentDefinition.js" ;
2727import { jsonDumps } from "../../chatWrappers/utils/jsonDumps.js" ;
2828import { defaultMaxPreloadTokens } from "../LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js" ;
29+ import { LlamaLogLevel } from "../../bindings/types.js" ;
2930import {
3031 eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy
3132} from "./utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js" ;
@@ -3081,6 +3082,25 @@ class GenerateResponseState<const Functions extends ChatModelFunctions | undefin
30813082 }
30823083
30833084 public async createNewEvaluationIterator ( ) {
3085+ if ( this . tokens . length === 0 ) {
3086+ if ( this . evaluationIterator != null )
3087+ return ;
3088+
3089+ const token = this . llamaChat . sequence . contextTokens . at ( - 1 ) ;
3090+ if ( token == null )
3091+ throw new Error ( "No tokens to evaluate" ) ;
3092+
3093+ this . llamaChat . sequence . model . _llama . _log (
3094+ LlamaLogLevel . warn ,
3095+ "Attempted to evaluate with no input, reevaluating the last context sequence token"
3096+ ) ;
3097+ await this . llamaChat . sequence . eraseContextTokenRanges ( [ {
3098+ start : this . llamaChat . sequence . contextTokens . length - 1 ,
3099+ end : this . llamaChat . sequence . contextTokens . length
3100+ } ] ) ;
3101+ this . tokens = [ token ] ;
3102+ }
3103+
30843104 if ( this . evaluationIterator != null )
30853105 await this . evaluationIterator . return ( ) ;
30863106
Original file line number Diff line number Diff line change @@ -1318,6 +1318,7 @@ export class LlamaContextSequence {
13181318 const newSequenceTokens = this . _contextTokens . slice ( ) ;
13191319 this . _nextTokenIndex = 0 ;
13201320 this . _context . _ctx . disposeSequence ( this . _sequenceId ) ;
1321+ this . _contextTokens = [ ] ;
13211322
13221323 // wait for the evaluation outside the "context" lock to avoid deadlocks
13231324 awaitPromise = this . evaluateWithoutGeneratingNewTokens ( newSequenceTokens , { _skipLock : skipLock } ) ;
You can’t perform that action at this time.
0 commit comments