|
1 | 1 | import { describe, it } from "vitest";
|
2 |
| -import { GGUFStrictType, GGUFMetadata, GGUFNonStrictType } from "./types"; |
| 2 | +import type { GGUFStrictType, GGUFMetadata, GGUFNonStrictType } from "./types"; |
3 | 3 |
|
4 | 4 | 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 |
6 | 7 | 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 |
9 | 10 | });
|
10 | 11 |
|
11 | 12 | it("GGUFStrictType should be correct (at compile time)", async () => {
|
| 13 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
12 | 14 | const model: GGUFMetadata<GGUFStrictType> = null as any;
|
13 | 15 |
|
14 | 16 | if (model["general.architecture"] === "whisper") {
|
15 | 17 | 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"; |
18 | 20 | }
|
19 | 21 |
|
20 | 22 | 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; |
23 | 25 | }
|
24 | 26 | 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; |
27 | 29 | model["tokenizer.ggml.eos_token_id"] = 1;
|
28 | 30 | }
|
29 | 31 |
|
30 | 32 | if (model["general.architecture"] === "mamba") {
|
31 | 33 | 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"; |
34 | 36 | }
|
35 | 37 | if (model["general.architecture"] === "llama") {
|
36 |
| - // @ts-expect-error |
| 38 | + // @ts-expect-error llama does not have ssm.* keys |
37 | 39 | model["mamba.ssm.conv_kernel"] = 0;
|
38 |
| - // @ts-expect-error |
39 |
| - model["mamba.ssm.conv_kernel"] = "abc"; // PASS, because it can be anything |
40 | 40 | }
|
41 | 41 | });
|
42 | 42 | });
|
0 commit comments