@huggingface/inference
Advanced tools
Comparing version 2.6.1 to 2.6.2
@@ -180,2 +180,10 @@ /// <reference path="./index.d.ts" /> | ||
})(); | ||
let credentials; | ||
if (typeof includeCredentials === "string") { | ||
credentials = includeCredentials; | ||
} else if (typeof includeCredentials === "boolean") { | ||
credentials = includeCredentials ? "include" : void 0; | ||
} else if (includeCredentials === void 0) { | ||
credentials = "same-origin"; | ||
} | ||
const info = { | ||
@@ -188,3 +196,3 @@ headers, | ||
}), | ||
credentials: includeCredentials ? "include" : "same-origin" | ||
credentials | ||
}; | ||
@@ -337,3 +345,3 @@ return { url, info }; | ||
} | ||
if (response.headers.get("content-type") !== "text/event-stream") { | ||
if (!response.headers.get("content-type")?.startsWith("text/event-stream")) { | ||
throw new Error( | ||
@@ -340,0 +348,0 @@ `Server does not support event stream content type, it returned ` + response.headers.get("content-type") |
@@ -27,2 +27,7 @@ export interface Options { | ||
fetch?: typeof fetch; | ||
/** | ||
* (Default: "same-origin"). String | Boolean. Credentials to use for the request. If this is a string, it will be passed straight on. If it's a boolean, true will be "include" and false will not send credentials at all. | ||
*/ | ||
includeCredentials?: string | boolean; | ||
} | ||
@@ -178,4 +183,2 @@ | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -193,4 +196,2 @@ task?: string | InferenceTask; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -1060,4 +1061,2 @@ task?: string | InferenceTask; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -1075,4 +1074,2 @@ task?: string | InferenceTask; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -1271,4 +1268,2 @@ task?: string | InferenceTask; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -1286,4 +1281,2 @@ task?: string | InferenceTask; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -1290,0 +1283,0 @@ task?: string | InferenceTask; |
@@ -180,2 +180,10 @@ /// <reference path="./index.d.ts" /> | ||
})(); | ||
let credentials; | ||
if (typeof includeCredentials === "string") { | ||
credentials = includeCredentials; | ||
} else if (typeof includeCredentials === "boolean") { | ||
credentials = includeCredentials ? "include" : void 0; | ||
} else if (includeCredentials === void 0) { | ||
credentials = "same-origin"; | ||
} | ||
const info = { | ||
@@ -188,3 +196,3 @@ headers, | ||
}), | ||
credentials: includeCredentials ? "include" : "same-origin" | ||
credentials | ||
}; | ||
@@ -337,3 +345,3 @@ return { url, info }; | ||
} | ||
if (response.headers.get("content-type") !== "text/event-stream") { | ||
if (!response.headers.get("content-type")?.startsWith("text/event-stream")) { | ||
throw new Error( | ||
@@ -340,0 +348,0 @@ `Server does not support event stream content type, it returned ` + response.headers.get("content-type") |
{ | ||
"name": "@huggingface/inference", | ||
"version": "2.6.1", | ||
"version": "2.6.2", | ||
"packageManager": "pnpm@8.3.1", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -21,4 +21,2 @@ import type { InferenceTask, Options, RequestArgs } from "../types"; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -87,2 +85,17 @@ forceTask?: string | InferenceTask; | ||
// Let users configure credentials, or disable them all together (or keep default behavior). | ||
// --- | ||
// This used to be an internal property only and never exposed to users. This means that most usages will never define this value | ||
// So in order to make this backwards compatible, if it's undefined we go to "same-origin" (default behaviour before). | ||
// If it's a boolean and set to true then set to "include". If false, don't define credentials at all (useful for edge runtimes) | ||
// Then finally, if it's a string, use it as-is. | ||
let credentials: RequestCredentials | undefined; | ||
if (typeof includeCredentials === "string") { | ||
credentials = includeCredentials as RequestCredentials; | ||
} else if (typeof includeCredentials === "boolean") { | ||
credentials = includeCredentials ? "include" : undefined; | ||
} else if (includeCredentials === undefined) { | ||
credentials = "same-origin"; | ||
} | ||
const info: RequestInit = { | ||
@@ -97,3 +110,3 @@ headers, | ||
}), | ||
credentials: includeCredentials ? "include" : "same-origin", | ||
credentials, | ||
}; | ||
@@ -100,0 +113,0 @@ |
@@ -10,4 +10,2 @@ import type { InferenceTask, Options, RequestArgs } from "../../types"; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -14,0 +12,0 @@ task?: string | InferenceTask; |
@@ -12,4 +12,2 @@ import type { InferenceTask, Options, RequestArgs } from "../../types"; | ||
options?: Options & { | ||
/** For internal HF use, which is why it's not exposed in {@link Options} */ | ||
includeCredentials?: boolean; | ||
/** When a model can be used for multiple tasks, and we want to run a non-default task */ | ||
@@ -40,3 +38,3 @@ task?: string | InferenceTask; | ||
} | ||
if (response.headers.get("content-type") !== "text/event-stream") { | ||
if (!response.headers.get("content-type")?.startsWith("text/event-stream")) { | ||
throw new Error( | ||
@@ -43,0 +41,0 @@ `Server does not support event stream content type, it returned ` + response.headers.get("content-type") |
@@ -27,2 +27,7 @@ export interface Options { | ||
fetch?: typeof fetch; | ||
/** | ||
* (Default: "same-origin"). String | Boolean. Credentials to use for the request. If this is a string, it will be passed straight on. If it's a boolean, true will be "include" and false will not send credentials at all. | ||
*/ | ||
includeCredentials?: string | boolean; | ||
} | ||
@@ -29,0 +34,0 @@ |
Sorry, the diff of this file is not supported yet
238197
6496