Skip to content

Commit 7878c8a

Browse files
authored
fix: fallback to general chat wrapper (#197)
1 parent 3ad4494 commit 7878c8a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

llama/addon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ class AddonContext : public Napi::ObjectWrap<AddonContext> {
10921092
return info.Env().Undefined();
10931093
}
10941094

1095-
return Napi::Number::From(info.Env(), llama_get_state_size(ctx));
1095+
return Napi::Number::From(info.Env(), llama_state_get_size(ctx));
10961096
}
10971097

10981098
Napi::Value PrintTimings(const Napi::CallbackInfo& info) {
@@ -1220,7 +1220,7 @@ class AddonContextLoadContextWorker : public Napi::AsyncWorker {
12201220
}
12211221
void OnOK() {
12221222
if (context->contextLoaded) {
1223-
uint64_t contextMemorySize = llama_get_state_size(context->ctx);
1223+
uint64_t contextMemorySize = llama_state_get_size(context->ctx);
12241224
adjustNapiExternalMemoryAdd(Env(), contextMemorySize);
12251225
context->loadedContextMemorySize = contextMemorySize;
12261226
}

src/chatWrappers/utils/resolveChatWrapper.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ export function resolveChatWrapper({
221221
return createSpecializedChatWrapper(LlamaChatWrapper);
222222

223223
return createSpecializedChatWrapper(GeneralChatWrapper);
224-
} else if (lowercaseName === "yarn" && firstSplitLowercaseSubType === "llama")
224+
} else if (lowercaseName === "codellama")
225+
return createSpecializedChatWrapper(GeneralChatWrapper);
226+
else if (lowercaseName === "yarn" && firstSplitLowercaseSubType === "llama")
225227
return createSpecializedChatWrapper(LlamaChatWrapper);
226228
else if (lowercaseName === "orca")
227229
return createSpecializedChatWrapper(ChatMLChatWrapper);
@@ -248,7 +250,7 @@ export function resolveChatWrapper({
248250
const arch = fileInfo.metadata.general?.architecture;
249251

250252
if (arch === "llama")
251-
return createSpecializedChatWrapper(LlamaChatWrapper);
253+
return createSpecializedChatWrapper(GeneralChatWrapper);
252254
else if (arch === "falcon")
253255
return createSpecializedChatWrapper(FalconChatWrapper);
254256
}

test/standalone/parseModelFileName.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ describe("parseModelFileName", () => {
2828
});
2929
});
3030

31+
test("codellama-7b.Q5_K_M.gguf", () => {
32+
expect(parseModelFileName("codellama-7b.Q5_K_M.gguf"))
33+
.toEqual({
34+
name: "codellama",
35+
subType: "",
36+
quantization: "Q5_K_M",
37+
fileType: "gguf",
38+
parameters: "7B",
39+
otherInfo: []
40+
});
41+
});
42+
3143
test("phind-codellama-34b-v2.Q4_K_M.gguf", () => {
3244
expect(parseModelFileName("phind-codellama-34b-v2.Q4_K_M.gguf"))
3345
.toEqual({

0 commit comments

Comments
 (0)