Skip to content

Commit 8767726

Browse files
committed
lint & format
1 parent 6d704bc commit 8767726

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

packages/gguf/src/gguf.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ describe("gguf", () => {
3737
"llama.rope.dimension_count": 128,
3838
});
3939

40-
expect(!!metadata["tokenizer.ggml.model"]);
41-
if (!!metadata["tokenizer.ggml.model"]) {
40+
expect(metadata["tokenizer.ggml.model"]);
41+
if (metadata["tokenizer.ggml.model"]) {
4242
const tokens = metadata["tokenizer.ggml.tokens"];
4343
if (!Array.isArray(tokens)) {
4444
throw new Error();

packages/gguf/src/types.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
import { describe, it } from "vitest";
2-
import { GGUFStrictType, GGUFMetadata, GGUFNonStrictType } from "./types";
2+
import type { GGUFStrictType, GGUFMetadata, GGUFNonStrictType } from "./types";
33

44
describe("gguf-types", () => {
5-
it("GGUFNonStrictType should be correct (at compile time)", async () => {
5+
it("GGUFNonStrictType should be correct (at compile time)", async () => {
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67
const model: GGUFMetadata<GGUFNonStrictType> = null as any;
7-
model.kv_count = 123n;
8-
model.abc = 456; // PASS, because it can be anything
8+
model.kv_count = 123n;
9+
model.abc = 456; // PASS, because it can be anything
910
});
1011

1112
it("GGUFStrictType should be correct (at compile time)", async () => {
13+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1214
const model: GGUFMetadata<GGUFStrictType> = null as any;
1315

1416
if (model["general.architecture"] === "whisper") {
1517
model["encoder.whisper.block_count"] = 0;
16-
// @ts-expect-error
17-
model["encoder.whisper.block_count"] = "abc"; // error, because it must be a number
18+
// @ts-expect-error because it must be a number
19+
model["encoder.whisper.block_count"] = "abc";
1820
}
1921

2022
if (model["tokenizer.ggml.model"] === undefined) {
21-
// @ts-expect-error
22-
model["tokenizer.ggml.eos_token_id"] = 1; // error, because it's undefined
23+
// @ts-expect-error because it's undefined
24+
model["tokenizer.ggml.eos_token_id"] = 1;
2325
}
2426
if (model["tokenizer.ggml.model"] === "gpt2") {
25-
// @ts-expect-error
26-
model["tokenizer.ggml.eos_token_id"] = undefined; // error, because it must be a number
27+
// @ts-expect-error because it must be a number
28+
model["tokenizer.ggml.eos_token_id"] = undefined;
2729
model["tokenizer.ggml.eos_token_id"] = 1;
2830
}
2931

3032
if (model["general.architecture"] === "mamba") {
3133
model["mamba.ssm.conv_kernel"] = 0;
32-
// @ts-expect-error
33-
model["mamba.ssm.conv_kernel"] = "abc"; // error, because it must be a number
34+
// @ts-expect-error because it must be a number
35+
model["mamba.ssm.conv_kernel"] = "abc";
3436
}
3537
if (model["general.architecture"] === "llama") {
36-
// @ts-expect-error
38+
// @ts-expect-error llama does not have ssm.* keys
3739
model["mamba.ssm.conv_kernel"] = 0;
38-
// @ts-expect-error
39-
model["mamba.ssm.conv_kernel"] = "abc"; // PASS, because it can be anything
4040
}
4141
});
4242
});

packages/gguf/src/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export interface GGUFGeneralInfo<TArchitecture extends Architecture> {
5858
}
5959

6060
type ModelMetadata = Whisper | RWKV | TransformerLLM;
61-
type NoModelMetadata = {
62-
"general.architecture"?: undefined,
63-
};
61+
interface NoModelMetadata {
62+
"general.architecture"?: undefined;
63+
}
6464

6565
export type ModelBase<
6666
TArchitecture extends
@@ -88,9 +88,9 @@ interface Tokenizer {
8888
"tokenizer.ggml.add_bos_token": boolean;
8989
"tokenizer.chat_template"?: string;
9090
}
91-
type NoTokenizer = {
92-
"tokenizer.ggml.model"?: undefined,
93-
};
91+
interface NoTokenizer {
92+
"tokenizer.ggml.model"?: undefined;
93+
}
9494

9595
/// Models outside of llama.cpp: "rwkv" and "whisper"
9696

0 commit comments

Comments
 (0)