Skip to content

Commit

Permalink
[gguf] Ability to specify some fetch headers (#653)
Browse files Browse the repository at this point in the history
cc @ngxson too

---------

Co-authored-by: Eliott C. <[email protected]>
  • Loading branch information
julien-c and coyotte508 authored May 3, 2024
1 parent 35992bb commit fe4fa20
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/gguf/src/gguf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class RangeView {
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
*/
fetch?: typeof fetch;
additionalFetchHeaders?: Record<string, string>;
}
) {
this.chunk = 0;
Expand All @@ -82,6 +83,7 @@ class RangeView {
await (
await (this.params?.fetch ?? fetch)(this.url, {
headers: {
...(this.params?.additionalFetchHeaders ?? {}),
Range: `bytes=${range[0]}-${range[1]}`,
},
})
Expand Down Expand Up @@ -209,6 +211,7 @@ export async function gguf(
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
*/
fetch?: typeof fetch;
additionalFetchHeaders?: Record<string, string>;
computeParametersCount: true;
}
): Promise<GGUFParseOutput & { parameterCount: number }>;
Expand All @@ -219,6 +222,7 @@ export async function gguf(
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
*/
fetch?: typeof fetch;
additionalFetchHeaders?: Record<string, string>;
}
): Promise<GGUFParseOutput>;
export async function gguf(
Expand All @@ -228,6 +232,7 @@ export async function gguf(
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
*/
fetch?: typeof fetch;
additionalFetchHeaders?: Record<string, string>;
computeParametersCount?: boolean;
}
): Promise<GGUFParseOutput & { parameterCount?: number }> {
Expand Down

0 comments on commit fe4fa20

Please sign in to comment.