Skip to content

Commit 5f547dd

Browse files
committed
style nits
1 parent c2afbdc commit 5f547dd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/gguf/src/types.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ import type { gguf } from "./gguf";
33
import type { GGUFMetadata, GGUFParseOutput, GGUFType } from "./types";
44

55
describe("gguf-types", () => {
6-
it("gguf() type can be casted (at compile time)", async () => {
6+
it("gguf() type can be casted between STRICT and NON_STRICT (at compile time)", async () => {
77
// eslint-disable-next-line @typescript-eslint/no-explicit-any
88
const result: Awaited<ReturnType<typeof gguf>> = null as any;
9-
const strictType = result as GGUFParseOutput<GGUFType.strict>;
9+
const strictType = result as GGUFParseOutput<GGUFType.STRICT>;
1010
// @ts-expect-error because the key "abc" does not exist
1111
strictType.metadata.abc = 123;
12-
const nonStrictType = result as GGUFParseOutput<GGUFType.nonStrict>;
12+
const nonStrictType = result as GGUFParseOutput<GGUFType.NON_STRICT>;
1313
nonStrictType.metadata.abc = 123; // PASS, because it can be anything
1414
// @ts-expect-error because ArrayBuffer is not a MetadataValue
1515
nonStrictType.metadata.fff = ArrayBuffer;
1616
});
1717

18-
it("GGUFType.nonStrict should be correct (at compile time)", async () => {
18+
it("GGUFType.NON_STRICT should be correct (at compile time)", async () => {
1919
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20-
const model: GGUFMetadata<GGUFType.nonStrict> = null as any;
20+
const model: GGUFMetadata<GGUFType.NON_STRICT> = null as any;
2121
model.kv_count = 123n;
2222
model.abc = 456; // PASS, because it can be anything
2323
});
2424

25-
it("GGUFType.strict should be correct (at compile time)", async () => {
25+
it("GGUFType.STRICT should be correct (at compile time)", async () => {
2626
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27-
const model: GGUFMetadata<GGUFType.strict> = null as any;
27+
const model: GGUFMetadata<GGUFType.STRICT> = null as any;
2828

2929
if (model["general.architecture"] === "whisper") {
3030
model["encoder.whisper.block_count"] = 0;

packages/gguf/src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ export type Whisper = GGUFGeneralInfo<"whisper"> &
111111
/// Types for parse output
112112

113113
export enum GGUFType {
114-
strict,
115-
nonStrict,
114+
STRICT,
115+
NON_STRICT,
116116
}
117117

118-
export type GGUFMetadata<TGGUFType extends GGUFType = GGUFType.strict> = {
118+
export type GGUFMetadata<TGGUFType extends GGUFType = GGUFType.STRICT> = {
119119
version: Version;
120120
tensor_count: bigint;
121121
kv_count: bigint;
122122
} & GGUFModelKV &
123-
(TGGUFType extends GGUFType.strict ? unknown : Record<string, MetadataValue>);
123+
(TGGUFType extends GGUFType.STRICT ? unknown : Record<string, MetadataValue>);
124124

125125
export type GGUFModelKV = (NoModelMetadata | ModelMetadata) & (NoTokenizer | Tokenizer);
126126

@@ -132,7 +132,7 @@ export interface GGUFTensorInfo {
132132
offset: bigint;
133133
}
134134

135-
export interface GGUFParseOutput<TGGUFType extends GGUFType = GGUFType.strict> {
135+
export interface GGUFParseOutput<TGGUFType extends GGUFType = GGUFType.STRICT> {
136136
metadata: GGUFMetadata<TGGUFType>;
137137
tensorInfos: GGUFTensorInfo[];
138138
}

0 commit comments

Comments
 (0)