Skip to content

Commit

Permalink
fix nextjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Dec 3, 2024
1 parent ac7dc45 commit e69313d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/model-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,13 @@ export class ModelManager {
if (Array.isArray(modelUrl)) {
return modelUrl;
}
const urlPartsRegex =
/(?<baseURL>.*)-(?<current>\d{5})-of-(?<total>\d{5})\.gguf$/;
const urlPartsRegex = /-(\d{5})-of-(\d{5})\.gguf$/;
const matches = modelUrl.match(urlPartsRegex);
if (
!matches ||
!matches.groups ||
Object.keys(matches.groups).length !== 3
) {
if (!matches) {
return [modelUrl];
}
const { baseURL, total } = matches.groups;
const baseURL = modelUrl.replace(urlPartsRegex, '');
const total = matches[2];
const paddedShardIds = Array.from({ length: Number(total) }, (_, index) =>
(index + 1).toString().padStart(5, '0')
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const textDecoder = new TextDecoder();
* @param buffer
* @returns a string
*/
export const bufToText = (buffer: ArrayBuffer): string => {
export const bufToText = (buffer: ArrayBuffer | Uint8Array): string => {
return textDecoder.decode(buffer);
};

Expand Down
1 change: 1 addition & 0 deletions src/wllama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export class Wllama {
if (stopTokens.includes(sampled.token)) {
break; // stop token
}
// @ts-ignore Type 'Uint8Array<ArrayBufferLike>' is not assignable to type 'Uint8Array<ArrayBuffer>'
outBuf = joinBuffers([outBuf, sampled.piece]);
if (options.onNewToken) {
options.onNewToken(sampled.token, sampled.piece, bufToText(outBuf), {
Expand Down
1 change: 1 addition & 0 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class ProxyToWorker {
args: [fileId, value, offset],
callbackId: this.taskId++,
},
// @ts-ignore Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'
[value.buffer]
);
offset += size;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"experimentalDecorators": true,

"noEmit": false,
"module": "es2020",
"module": "es2015",
"outDir": "esm",
"rootDir": "./src",
"baseUrl": ".",
Expand Down

0 comments on commit e69313d

Please sign in to comment.