Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gguf/src/gguf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class RangeViewLocalFile extends RangeView {
override async fetchChunk(): Promise<void> {
const { FileBlob } = await import("./utils/FileBlob");
const blob = await FileBlob.create(this.uri);
const range = [this.chunk * HTTP_CHUNK_SIZE, (this.chunk + 1) * HTTP_CHUNK_SIZE - 1];
const range = [this.chunk * HTTP_CHUNK_SIZE, (this.chunk + 1) * HTTP_CHUNK_SIZE];
const buffer = await blob.slice(range[0], range[1]).arrayBuffer();
this.appendBuffer(new Uint8Array(buffer));
this.chunk += 1;
Expand Down
4 changes: 3 additions & 1 deletion packages/gguf/src/utils/FileBlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class FileBlob extends Blob {
new TypeError("Unsupported negative start/end on FileBlob.slice");
}

const slice = new FileBlob(this.path, this.start + start, Math.min(this.start + end, this.end));
const newStart = Math.min(this.start + start, this.end);
const newEnd = Math.min(this.start + end, this.end);
const slice = new FileBlob(this.path, newStart, newEnd);

return slice;
}
Expand Down