Skip to content

Commit 140d888

Browse files
committed
fix: bugs
1 parent 6191ee2 commit 140d888

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/bindings/utils/getLlamaGpuTypes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/evaluator/LlamaChat/LlamaChat.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {LlamaModel} from "../LlamaModel/LlamaModel.js";
2626
import {getChatWrapperSegmentDefinition} from "../../utils/getChatWrapperSegmentDefinition.js";
2727
import {jsonDumps} from "../../chatWrappers/utils/jsonDumps.js";
2828
import {defaultMaxPreloadTokens} from "../LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js";
29+
import {LlamaLogLevel} from "../../bindings/types.js";
2930
import {
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

src/evaluator/LlamaContext/LlamaContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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});

0 commit comments

Comments
 (0)