From e78bc6754fc87166bb3ce1d10b9ae613c90f159f Mon Sep 17 00:00:00 2001 From: Mishig Date: Thu, 11 Apr 2024 16:49:34 +0200 Subject: [PATCH] [gguf] RE_GGUF_SHARD_FILE named groups (#621) Suggested by @coyotte508 --- packages/gguf/src/gguf.spec.ts | 4 ++-- packages/gguf/src/gguf.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/gguf/src/gguf.spec.ts b/packages/gguf/src/gguf.spec.ts index eaa3b1437..fcd20a375 100644 --- a/packages/gguf/src/gguf.spec.ts +++ b/packages/gguf/src/gguf.spec.ts @@ -226,7 +226,7 @@ describe("gguf", () => { const match = ggufPath.match(RE_GGUF_SHARD_FILE); expect(RE_GGUF_SHARD_FILE.test(ggufPath)).toEqual(true); - expect(match?.[1]).toEqual("00003"); - expect(match?.[2]).toEqual("00009"); + expect(match?.groups?.shard).toEqual("00003"); + expect(match?.groups?.total).toEqual("00009"); }); }); diff --git a/packages/gguf/src/gguf.ts b/packages/gguf/src/gguf.ts index cbcc5350c..050bacabe 100644 --- a/packages/gguf/src/gguf.ts +++ b/packages/gguf/src/gguf.ts @@ -6,7 +6,7 @@ export { GGUFValueType, GGMLQuantizationType } from "./types"; export { GGUF_QUANT_DESCRIPTIONS } from "./quant-descriptions"; export const RE_GGUF_FILE = /\.gguf$/; -export const RE_GGUF_SHARD_FILE = /-(\d{5})-of-(\d{5})\.gguf$/; +export const RE_GGUF_SHARD_FILE = /-(?\d{5})-of-(?\d{5})\.gguf$/; const isVersion = (version: number): version is Version => version === 1 || version === 2 || version === 3;