Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
•
2204ef8
1
Parent(s):
9feaf31
Sync widgets demo
Browse files
packages/widgets/src/lib/components/InferenceWidget/shared/helpers.ts
CHANGED
@@ -101,11 +101,7 @@ export async function callInferenceApi<T>(
|
|
101 |
useCache = true
|
102 |
): Promise<Result<T>> {
|
103 |
const contentType =
|
104 |
-
"file" in requestBody &&
|
105 |
-
requestBody["file"] &&
|
106 |
-
typeof requestBody["file"] === "object" &&
|
107 |
-
"type" in requestBody["file"] &&
|
108 |
-
typeof requestBody["file"]["type"] === "string"
|
109 |
? requestBody["file"]["type"]
|
110 |
: "application/json";
|
111 |
|
@@ -124,8 +120,9 @@ export async function callInferenceApi<T>(
|
|
124 |
headers.set("X-Load-Model", "0");
|
125 |
}
|
126 |
|
127 |
-
|
128 |
-
|
|
|
129 |
|
130 |
const response = await fetch(`${url}/models/${repoId}`, {
|
131 |
method: "POST",
|
|
|
101 |
useCache = true
|
102 |
): Promise<Result<T>> {
|
103 |
const contentType =
|
104 |
+
"file" in requestBody && requestBody["file"] && requestBody["file"] instanceof Blob && requestBody["file"].type
|
|
|
|
|
|
|
|
|
105 |
? requestBody["file"]["type"]
|
106 |
: "application/json";
|
107 |
|
|
|
120 |
headers.set("X-Load-Model", "0");
|
121 |
}
|
122 |
|
123 |
+
// `File` is a subtype of `Blob`: therefore, checking for instanceof `Blob` also checks for instanceof `File`
|
124 |
+
const reqBody: Blob | string =
|
125 |
+
"file" in requestBody && requestBody["file"] instanceof Blob ? requestBody.file : JSON.stringify(requestBody);
|
126 |
|
127 |
const response = await fetch(`${url}/models/${repoId}`, {
|
128 |
method: "POST",
|