@gradio/client 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/README.md +32 -32
- package/dist/client.d.ts +15 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/index.js +93 -76
- package/dist/types.d.ts +11 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/client.ts +155 -111
- package/src/globals.d.ts +1 -3
- package/src/types.ts +12 -5
- package/src/utils.ts +14 -13
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# @gradio/client
|
2
2
|
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#5267](https://github.com/gradio-app/gradio/pull/5267) [`119c8343`](https://github.com/gradio-app/gradio/commit/119c834331bfae60d4742c8f20e9cdecdd67e8c2) - Faster reload mode. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
8
|
+
|
9
|
+
## 0.2.1
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
- [#5173](https://github.com/gradio-app/gradio/pull/5173) [`730f0c1d`](https://github.com/gradio-app/gradio/commit/730f0c1d54792eb11359e40c9f2326e8a6e39203) - Ensure gradio client works as expected for functions that return nothing. Thanks [@raymondtri](https://github.com/raymondtri)!
|
14
|
+
|
15
|
+
## 0.2.0
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
- [#5133](https://github.com/gradio-app/gradio/pull/5133) [`61129052`](https://github.com/gradio-app/gradio/commit/61129052ed1391a75c825c891d57fa0ad6c09fc8) - Update dependency esbuild to ^0.19.0. Thanks [@renovate](https://github.com/apps/renovate)!
|
20
|
+
- [#5035](https://github.com/gradio-app/gradio/pull/5035) [`8b4eb8ca`](https://github.com/gradio-app/gradio/commit/8b4eb8cac9ea07bde31b44e2006ca2b7b5f4de36) - JS Client: Fixes cannot read properties of null (reading 'is_file'). Thanks [@raymondtri](https://github.com/raymondtri)!
|
21
|
+
|
22
|
+
### Fixes
|
23
|
+
|
24
|
+
- [#5075](https://github.com/gradio-app/gradio/pull/5075) [`67265a58`](https://github.com/gradio-app/gradio/commit/67265a58027ef1f9e4c0eb849a532f72eaebde48) - Allow supporting >1000 files in `gr.File()` and `gr.UploadButton()`. Thanks [@abidlabs](https://github.com/abidlabs)!
|
25
|
+
|
3
26
|
## 0.1.4
|
4
27
|
|
5
28
|
### Patch Changes
|
@@ -40,4 +63,4 @@
|
|
40
63
|
|
41
64
|
- [#3692](https://github.com/gradio-app/gradio/pull/3692) [`48e8b113`](https://github.com/gradio-app/gradio/commit/48e8b113f4b55e461d9da4f153bf72aeb4adf0f1) Thanks [@pngwn](https://github.com/pngwn)! - Ensure client works in node, create ESM bundle and generate typescript declaration files.
|
42
65
|
|
43
|
-
- [#3605](https://github.com/gradio-app/gradio/pull/3605) [`ae4277a9`](https://github.com/gradio-app/gradio/commit/ae4277a9a83d49bdadfe523b0739ba988128e73b) Thanks [@pngwn](https://github.com/pngwn)! - Update readme.
|
66
|
+
- [#3605](https://github.com/gradio-app/gradio/pull/3605) [`ae4277a9`](https://github.com/gradio-app/gradio/commit/ae4277a9a83d49bdadfe523b0739ba988128e73b) Thanks [@pngwn](https://github.com/pngwn)! - Update readme.
|
package/README.md
CHANGED
@@ -65,8 +65,8 @@ Applications hosted on Hugging Face spaces can be in a number of different state
|
|
65
65
|
import { client, type SpaceStatus } from "@gradio/client";
|
66
66
|
|
67
67
|
const app = await client("user/space-name", {
|
68
|
-
|
69
|
-
|
68
|
+
// The space_status parameter does not need to be manually annotated, this is just for illustration.
|
69
|
+
space_status: (space_status: SpaceStatus) => console.log(space_status)
|
70
70
|
});
|
71
71
|
```
|
72
72
|
|
@@ -157,22 +157,22 @@ The status payload look like this:
|
|
157
157
|
|
158
158
|
```ts
|
159
159
|
interface Status {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
160
|
+
queue: boolean;
|
161
|
+
code?: string;
|
162
|
+
success?: boolean;
|
163
|
+
stage: "pending" | "error" | "complete" | "generating";
|
164
|
+
size?: number;
|
165
|
+
position?: number;
|
166
|
+
eta?: number;
|
167
|
+
message?: string;
|
168
|
+
progress_data?: Array<{
|
169
|
+
progress: number | null;
|
170
|
+
index: number | null;
|
171
|
+
length: number | null;
|
172
|
+
unit: string | null;
|
173
|
+
desc: string | null;
|
174
|
+
}>;
|
175
|
+
time?: Date;
|
176
176
|
}
|
177
177
|
```
|
178
178
|
|
@@ -183,9 +183,9 @@ import { client } from "@gradio/client";
|
|
183
183
|
|
184
184
|
const app = await client("user/space-name");
|
185
185
|
const submission = app
|
186
|
-
|
187
|
-
|
188
|
-
|
186
|
+
.submit("/predict", payload)
|
187
|
+
.on("data", (data) => console.log(data))
|
188
|
+
.on("status", (status: Status) => console.log(status));
|
189
189
|
```
|
190
190
|
|
191
191
|
##### `off`
|
@@ -229,8 +229,8 @@ import { client } from "@gradio/client";
|
|
229
229
|
|
230
230
|
const app = await client("user/space-name");
|
231
231
|
const submission = app
|
232
|
-
|
233
|
-
|
232
|
+
.submit("/predict", payload)
|
233
|
+
.on("data", (data) => console.log(data));
|
234
234
|
|
235
235
|
// later
|
236
236
|
|
@@ -271,7 +271,7 @@ The duplicate function will attempt to duplicate the space that is referenced an
|
|
271
271
|
import { duplicate } from "@gradio/client";
|
272
272
|
|
273
273
|
const app = await duplicate("user/space-name", {
|
274
|
-
|
274
|
+
hf_token: "hf_..."
|
275
275
|
});
|
276
276
|
```
|
277
277
|
|
@@ -295,8 +295,8 @@ This is an optional property specific to `duplicate`'s options object and will d
|
|
295
295
|
import { duplicate } from "@gradio/client";
|
296
296
|
|
297
297
|
const app = await duplicate("user/space-name", {
|
298
|
-
|
299
|
-
|
298
|
+
hf_token: "hf_...",
|
299
|
+
private: true
|
300
300
|
});
|
301
301
|
```
|
302
302
|
|
@@ -308,9 +308,9 @@ This is an optional property specific to `duplicate`'s options object and will s
|
|
308
308
|
import { duplicate } from "@gradio/client";
|
309
309
|
|
310
310
|
const app = await duplicate("user/space-name", {
|
311
|
-
|
312
|
-
|
313
|
-
|
311
|
+
hf_token: "hf_...",
|
312
|
+
private: true,
|
313
|
+
timeout: 5
|
314
314
|
});
|
315
315
|
```
|
316
316
|
|
@@ -332,8 +332,8 @@ Possible hardware options are:
|
|
332
332
|
import { duplicate } from "@gradio/client";
|
333
333
|
|
334
334
|
const app = await duplicate("user/space-name", {
|
335
|
-
|
336
|
-
|
337
|
-
|
335
|
+
hf_token: "hf_...",
|
336
|
+
private: true,
|
337
|
+
hardware: "a10g-small"
|
338
338
|
});
|
339
339
|
```
|
package/dist/client.d.ts
CHANGED
@@ -20,27 +20,25 @@ export declare function duplicate(app_reference: string, options: {
|
|
20
20
|
hf_token: `hf_${string}`;
|
21
21
|
private?: boolean;
|
22
22
|
status_callback: SpaceStatusCallback;
|
23
|
-
hardware?: typeof hardware_types[number];
|
23
|
+
hardware?: (typeof hardware_types)[number];
|
24
24
|
timeout?: number;
|
25
25
|
}): Promise<client_return>;
|
26
|
-
|
27
|
-
* We need to inject a customized fetch implementation for the Wasm version.
|
28
|
-
*/
|
29
|
-
export declare function api_factory(fetch_implementation: typeof fetch): {
|
26
|
+
interface Client {
|
30
27
|
post_data: (url: string, body: unknown, token?: `hf_${string}`) => Promise<[PostResponse, number]>;
|
31
|
-
upload_files: (root: string, files:
|
32
|
-
client: (app_reference: string, options
|
28
|
+
upload_files: (root: string, files: File[], token?: `hf_${string}`) => Promise<UploadResponse>;
|
29
|
+
client: (app_reference: string, options: {
|
33
30
|
hf_token?: `hf_${string}`;
|
34
31
|
status_callback?: SpaceStatusCallback;
|
35
32
|
normalise_files?: boolean;
|
36
33
|
}) => Promise<client_return>;
|
37
|
-
handle_blob: (endpoint: string, data: unknown[], api_info:
|
38
|
-
}
|
39
|
-
export declare
|
34
|
+
handle_blob: (endpoint: string, data: unknown[], api_info: ApiInfo<JsApiData>, token?: `hf_${string}`) => Promise<unknown[]>;
|
35
|
+
}
|
36
|
+
export declare function api_factory(fetch_implementation: typeof fetch): Client;
|
37
|
+
export declare const post_data: (url: string, body: unknown, token?: `hf_${string}`) => Promise<[PostResponse, number]>, upload_files: (root: string, files: File[], token?: `hf_${string}`) => Promise<UploadResponse>, client: (app_reference: string, options: {
|
40
38
|
hf_token?: `hf_${string}`;
|
41
39
|
status_callback?: SpaceStatusCallback;
|
42
40
|
normalise_files?: boolean;
|
43
|
-
}) => Promise<client_return>, handle_blob: (endpoint: string, data: unknown[], api_info:
|
41
|
+
}) => Promise<client_return>, handle_blob: (endpoint: string, data: unknown[], api_info: ApiInfo<JsApiData>, token?: `hf_${string}`) => Promise<unknown[]>;
|
44
42
|
interface ApiData {
|
45
43
|
label: string;
|
46
44
|
type: {
|
@@ -68,6 +66,11 @@ interface ApiInfo<T extends ApiData | JsApiData> {
|
|
68
66
|
[key: string]: EndpointInfo<T>;
|
69
67
|
};
|
70
68
|
}
|
71
|
-
export declare function walk_and_store_blobs(param: any, type?: any, path?: any[], root?: boolean, api_info?: any): Promise<
|
69
|
+
export declare function walk_and_store_blobs(param: any, type?: any, path?: any[], root?: boolean, api_info?: any): Promise<{
|
70
|
+
path: string[];
|
71
|
+
data: string | false;
|
72
|
+
type: string;
|
73
|
+
blob: Blob | false;
|
74
|
+
}[]>;
|
72
75
|
export {};
|
73
76
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAQN,cAAc,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACX,SAAS,EACT,aAAa,EAI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I,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC;CACnB,EAAE,CACH,CAsEA"}
|
package/dist/index.js
CHANGED
@@ -13,13 +13,12 @@ function determine_protocol(endpoint) {
|
|
13
13
|
host,
|
14
14
|
http_protocol: protocol
|
15
15
|
};
|
16
|
-
} else {
|
17
|
-
return {
|
18
|
-
ws_protocol: protocol === "https:" ? "wss" : "ws",
|
19
|
-
http_protocol: protocol,
|
20
|
-
host
|
21
|
-
};
|
22
16
|
}
|
17
|
+
return {
|
18
|
+
ws_protocol: protocol === "https:" ? "wss" : "ws",
|
19
|
+
http_protocol: protocol,
|
20
|
+
host
|
21
|
+
};
|
23
22
|
}
|
24
23
|
return {
|
25
24
|
ws_protocol: "wss",
|
@@ -86,8 +85,7 @@ async function discussions_enabled(space_id) {
|
|
86
85
|
const error = r.headers.get("x-error-message");
|
87
86
|
if (error && RE_DISABLED_DISCUSSION.test(error))
|
88
87
|
return false;
|
89
|
-
|
90
|
-
return true;
|
88
|
+
return true;
|
91
89
|
} catch (e) {
|
92
90
|
return false;
|
93
91
|
}
|
@@ -193,25 +191,20 @@ async function duplicate(app_reference, options) {
|
|
193
191
|
);
|
194
192
|
if (response.status === 409) {
|
195
193
|
return client(`${user}/${space_name}`, options);
|
196
|
-
} else {
|
197
|
-
const duplicated_space = await response.json();
|
198
|
-
let original_hardware;
|
199
|
-
if (!hardware) {
|
200
|
-
original_hardware = await get_space_hardware(app_reference, hf_token);
|
201
|
-
}
|
202
|
-
const requested_hardware = hardware || original_hardware || "cpu-basic";
|
203
|
-
await set_space_hardware(
|
204
|
-
`${user}/${space_name}`,
|
205
|
-
requested_hardware,
|
206
|
-
hf_token
|
207
|
-
);
|
208
|
-
await set_space_timeout(
|
209
|
-
`${user}/${space_name}`,
|
210
|
-
timeout || 300,
|
211
|
-
hf_token
|
212
|
-
);
|
213
|
-
return client(duplicated_space.url, options);
|
214
194
|
}
|
195
|
+
const duplicated_space = await response.json();
|
196
|
+
let original_hardware;
|
197
|
+
if (!hardware) {
|
198
|
+
original_hardware = await get_space_hardware(app_reference, hf_token);
|
199
|
+
}
|
200
|
+
const requested_hardware = hardware || original_hardware || "cpu-basic";
|
201
|
+
await set_space_hardware(
|
202
|
+
`${user}/${space_name}`,
|
203
|
+
requested_hardware,
|
204
|
+
hf_token
|
205
|
+
);
|
206
|
+
await set_space_timeout(`${user}/${space_name}`, timeout || 300, hf_token);
|
207
|
+
return client(duplicated_space.url, options);
|
215
208
|
} catch (e) {
|
216
209
|
throw new Error(e);
|
217
210
|
}
|
@@ -240,21 +233,27 @@ function api_factory(fetch_implementation) {
|
|
240
233
|
if (token) {
|
241
234
|
headers.Authorization = `Bearer ${token}`;
|
242
235
|
}
|
243
|
-
const
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
body: formData,
|
251
|
-
headers
|
236
|
+
const chunkSize = 1e3;
|
237
|
+
const uploadResponses = [];
|
238
|
+
for (let i = 0; i < files.length; i += chunkSize) {
|
239
|
+
const chunk = files.slice(i, i + chunkSize);
|
240
|
+
const formData = new FormData();
|
241
|
+
chunk.forEach((file) => {
|
242
|
+
formData.append("files", file);
|
252
243
|
});
|
253
|
-
|
254
|
-
|
244
|
+
try {
|
245
|
+
var response = await fetch_implementation(`${root}/upload`, {
|
246
|
+
method: "POST",
|
247
|
+
body: formData,
|
248
|
+
headers
|
249
|
+
});
|
250
|
+
} catch (e) {
|
251
|
+
return { error: BROKEN_CONNECTION_MSG };
|
252
|
+
}
|
253
|
+
const output = await response.json();
|
254
|
+
uploadResponses.push(...output);
|
255
255
|
}
|
256
|
-
|
257
|
-
return { files: output };
|
256
|
+
return { files: uploadResponses };
|
258
257
|
}
|
259
258
|
async function client2(app_reference, options = { normalise_files: true }) {
|
260
259
|
return new Promise(async (res) => {
|
@@ -347,22 +346,37 @@ function api_factory(fetch_implementation) {
|
|
347
346
|
function predict(endpoint, data, event_data) {
|
348
347
|
let data_returned = false;
|
349
348
|
let status_complete = false;
|
349
|
+
let dependency;
|
350
|
+
if (typeof endpoint === "number") {
|
351
|
+
dependency = config.dependencies[endpoint];
|
352
|
+
} else {
|
353
|
+
const trimmed_endpoint = endpoint.replace(/^\//, "");
|
354
|
+
dependency = config.dependencies[api_map[trimmed_endpoint]];
|
355
|
+
}
|
356
|
+
if (dependency.types.continuous) {
|
357
|
+
throw new Error(
|
358
|
+
"Cannot call predict on this function as it may run forever. Use submit instead"
|
359
|
+
);
|
360
|
+
}
|
350
361
|
return new Promise((res2, rej) => {
|
351
362
|
const app = submit(endpoint, data, event_data);
|
363
|
+
let result;
|
352
364
|
app.on("data", (d) => {
|
353
|
-
data_returned = true;
|
354
365
|
if (status_complete) {
|
355
366
|
app.destroy();
|
367
|
+
res2(d);
|
356
368
|
}
|
357
|
-
|
369
|
+
data_returned = true;
|
370
|
+
result = d;
|
358
371
|
}).on("status", (status) => {
|
359
372
|
if (status.stage === "error")
|
360
373
|
rej(status);
|
361
|
-
if (status.stage === "complete" && data_returned) {
|
362
|
-
app.destroy();
|
363
|
-
}
|
364
374
|
if (status.stage === "complete") {
|
365
375
|
status_complete = true;
|
376
|
+
app.destroy();
|
377
|
+
if (data_returned) {
|
378
|
+
res2(result);
|
379
|
+
}
|
366
380
|
}
|
367
381
|
});
|
368
382
|
});
|
@@ -477,6 +491,7 @@ function api_factory(fetch_implementation) {
|
|
477
491
|
fire_event({
|
478
492
|
type: "status",
|
479
493
|
stage: "error",
|
494
|
+
broken: true,
|
480
495
|
message: BROKEN_CONNECTION_MSG,
|
481
496
|
queue: true,
|
482
497
|
endpoint: _endpoint,
|
@@ -509,6 +524,14 @@ function api_factory(fetch_implementation) {
|
|
509
524
|
websocket.send(JSON.stringify({ ...payload, session_hash }));
|
510
525
|
} else if (type === "complete") {
|
511
526
|
complete = status;
|
527
|
+
} else if (type === "log") {
|
528
|
+
fire_event({
|
529
|
+
type: "log",
|
530
|
+
log: data2.log,
|
531
|
+
level: data2.level,
|
532
|
+
endpoint: _endpoint,
|
533
|
+
fn_index
|
534
|
+
});
|
512
535
|
} else if (type === "generating") {
|
513
536
|
fire_event({
|
514
537
|
type: "status",
|
@@ -676,9 +699,8 @@ function api_factory(fetch_implementation) {
|
|
676
699
|
if (blob) {
|
677
700
|
const file_url = (await upload_files2(endpoint, [blob], token)).files[0];
|
678
701
|
return { path, file_url, type };
|
679
|
-
} else {
|
680
|
-
return { path, base64: data2, type };
|
681
702
|
}
|
703
|
+
return { path, base64: data2, type };
|
682
704
|
})
|
683
705
|
).then((r) => {
|
684
706
|
r.forEach(({ path, file_url, base64, type }) => {
|
@@ -704,17 +726,16 @@ const { post_data, upload_files, client, handle_blob } = api_factory(fetch);
|
|
704
726
|
function transform_output(data, api_info, root_url, remote_url) {
|
705
727
|
return data.map((d, i) => {
|
706
728
|
var _a, _b, _c, _d;
|
707
|
-
if (((_b = (_a = api_info.returns) == null ? void 0 : _a[i]) == null ? void 0 : _b.component) === "File") {
|
729
|
+
if (((_b = (_a = api_info == null ? void 0 : api_info.returns) == null ? void 0 : _a[i]) == null ? void 0 : _b.component) === "File") {
|
708
730
|
return normalise_file(d, root_url, remote_url);
|
709
|
-
} else if (((_d = (_c = api_info.returns) == null ? void 0 : _c[i]) == null ? void 0 : _d.component) === "Gallery") {
|
731
|
+
} else if (((_d = (_c = api_info == null ? void 0 : api_info.returns) == null ? void 0 : _c[i]) == null ? void 0 : _d.component) === "Gallery") {
|
710
732
|
return d.map((img) => {
|
711
733
|
return Array.isArray(img) ? [normalise_file(img[0], root_url, remote_url), img[1]] : [normalise_file(img, root_url, remote_url), null];
|
712
734
|
});
|
713
|
-
} else if (typeof d === "object" && d.is_file) {
|
735
|
+
} else if (typeof d === "object" && (d == null ? void 0 : d.is_file)) {
|
714
736
|
return normalise_file(d, root_url, remote_url);
|
715
|
-
} else {
|
716
|
-
return d;
|
717
737
|
}
|
738
|
+
return d;
|
718
739
|
});
|
719
740
|
}
|
720
741
|
function normalise_file(file, root, root_url) {
|
@@ -762,9 +783,8 @@ function get_type(type, component, serializer, signature_type) {
|
|
762
783
|
} else if (serializer === "FileSerializable") {
|
763
784
|
if ((type == null ? void 0 : type.type) === "array") {
|
764
785
|
return signature_type === "parameter" ? "(Blob | File | Buffer)[]" : `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]`;
|
765
|
-
} else {
|
766
|
-
return signature_type === "parameter" ? "Blob | File | Buffer" : `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}`;
|
767
786
|
}
|
787
|
+
return signature_type === "parameter" ? "Blob | File | Buffer" : `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}`;
|
768
788
|
} else if (serializer === "GallerySerializable") {
|
769
789
|
return signature_type === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : `[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]`;
|
770
790
|
}
|
@@ -776,9 +796,8 @@ function get_description(type, serializer) {
|
|
776
796
|
return "array of strings";
|
777
797
|
} else if (serializer === "FileSerializable") {
|
778
798
|
return "array of files or single file";
|
779
|
-
} else {
|
780
|
-
return type.description;
|
781
799
|
}
|
800
|
+
return type.description;
|
782
801
|
}
|
783
802
|
function transform_api_info(api_info, config, api_map) {
|
784
803
|
const new_data = {
|
@@ -872,10 +891,9 @@ async function walk_and_store_blobs(param, type = void 0, path = [], root = fals
|
|
872
891
|
const buffer = await param.arrayBuffer();
|
873
892
|
data = Buffer.from(buffer).toString("base64");
|
874
893
|
}
|
875
|
-
return [{ path, data, type }];
|
876
|
-
} else {
|
877
|
-
return [{ path, blob: param, type }];
|
894
|
+
return [{ path, data, type, blob: false }];
|
878
895
|
}
|
896
|
+
return [{ path, blob: param, type, data: false }];
|
879
897
|
} else if (typeof param === "object") {
|
880
898
|
let blob_refs = [];
|
881
899
|
for (let key in param) {
|
@@ -894,9 +912,8 @@ async function walk_and_store_blobs(param, type = void 0, path = [], root = fals
|
|
894
912
|
}
|
895
913
|
}
|
896
914
|
return blob_refs;
|
897
|
-
} else {
|
898
|
-
return [];
|
899
915
|
}
|
916
|
+
return [];
|
900
917
|
}
|
901
918
|
function image_to_data_uri(blob) {
|
902
919
|
return new Promise((resolve, _) => {
|
@@ -914,7 +931,7 @@ async function resolve_config(fetch_implementation, endpoint, token) {
|
|
914
931
|
if (token) {
|
915
932
|
headers.Authorization = `Bearer ${token}`;
|
916
933
|
}
|
917
|
-
if (typeof window !== "undefined" && window.gradio_config && location.origin !== "http://localhost:9876") {
|
934
|
+
if (typeof window !== "undefined" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
|
918
935
|
const path = window.gradio_config.root;
|
919
936
|
const config = window.gradio_config;
|
920
937
|
config.root = endpoint + config.root;
|
@@ -928,9 +945,8 @@ async function resolve_config(fetch_implementation, endpoint, token) {
|
|
928
945
|
config.path = config.path ?? "";
|
929
946
|
config.root = endpoint;
|
930
947
|
return config;
|
931
|
-
} else {
|
932
|
-
throw new Error("Could not get config.");
|
933
948
|
}
|
949
|
+
throw new Error("Could not get config.");
|
934
950
|
}
|
935
951
|
throw new Error("No config or app endpoint found");
|
936
952
|
}
|
@@ -1055,6 +1071,8 @@ function handle_message(data, last_status) {
|
|
1055
1071
|
success: data.success
|
1056
1072
|
}
|
1057
1073
|
};
|
1074
|
+
case "log":
|
1075
|
+
return { type: "log", data };
|
1058
1076
|
case "process_generating":
|
1059
1077
|
return {
|
1060
1078
|
type: "generating",
|
@@ -1080,20 +1098,19 @@ function handle_message(data, last_status) {
|
|
1080
1098
|
success: data.success
|
1081
1099
|
}
|
1082
1100
|
};
|
1083
|
-
} else {
|
1084
|
-
return {
|
1085
|
-
type: "complete",
|
1086
|
-
status: {
|
1087
|
-
queue,
|
1088
|
-
message: !data.success ? data.output.error : void 0,
|
1089
|
-
stage: data.success ? "complete" : "error",
|
1090
|
-
code: data.code,
|
1091
|
-
progress_data: data.progress_data,
|
1092
|
-
eta: data.output.average_duration
|
1093
|
-
},
|
1094
|
-
data: data.success ? data.output : null
|
1095
|
-
};
|
1096
1101
|
}
|
1102
|
+
return {
|
1103
|
+
type: "complete",
|
1104
|
+
status: {
|
1105
|
+
queue,
|
1106
|
+
message: !data.success ? data.output.error : void 0,
|
1107
|
+
stage: data.success ? "complete" : "error",
|
1108
|
+
code: data.code,
|
1109
|
+
progress_data: data.progress_data,
|
1110
|
+
eta: data.output.average_duration
|
1111
|
+
},
|
1112
|
+
data: data.success ? data.output : null
|
1113
|
+
};
|
1097
1114
|
case "process_starts":
|
1098
1115
|
return {
|
1099
1116
|
type: "update",
|
package/dist/types.d.ts
CHANGED
@@ -20,7 +20,7 @@ export interface Config {
|
|
20
20
|
path: string;
|
21
21
|
}
|
22
22
|
export interface Payload {
|
23
|
-
data:
|
23
|
+
data: unknown[];
|
24
24
|
fn_index?: number;
|
25
25
|
event_data?: unknown;
|
26
26
|
time?: Date;
|
@@ -31,26 +31,31 @@ export interface PostResponse {
|
|
31
31
|
}
|
32
32
|
export interface UploadResponse {
|
33
33
|
error?: string;
|
34
|
-
files?:
|
34
|
+
files?: string[];
|
35
35
|
}
|
36
36
|
export interface Status {
|
37
37
|
queue: boolean;
|
38
38
|
code?: string;
|
39
39
|
success?: boolean;
|
40
40
|
stage: "pending" | "error" | "complete" | "generating";
|
41
|
+
broken?: boolean;
|
41
42
|
size?: number;
|
42
43
|
position?: number;
|
43
44
|
eta?: number;
|
44
45
|
message?: string;
|
45
|
-
progress_data?:
|
46
|
+
progress_data?: {
|
46
47
|
progress: number | null;
|
47
48
|
index: number | null;
|
48
49
|
length: number | null;
|
49
50
|
unit: string | null;
|
50
51
|
desc: string | null;
|
51
|
-
}
|
52
|
+
}[];
|
52
53
|
time?: Date;
|
53
54
|
}
|
55
|
+
export interface LogMessage {
|
56
|
+
log: string;
|
57
|
+
level: "warning" | "info";
|
58
|
+
}
|
54
59
|
export interface SpaceStatusNormal {
|
55
60
|
status: "sleeping" | "running" | "building" | "error" | "stopped";
|
56
61
|
detail: "SLEEPING" | "RUNNING" | "RUNNING_BUILDING" | "BUILDING" | "NOT_FOUND";
|
@@ -67,10 +72,11 @@ export interface SpaceStatusError {
|
|
67
72
|
export type SpaceStatus = SpaceStatusNormal | SpaceStatusError;
|
68
73
|
export type status_callback_function = (a: Status) => void;
|
69
74
|
export type SpaceStatusCallback = (a: SpaceStatus) => void;
|
70
|
-
export type EventType = "data" | "status";
|
75
|
+
export type EventType = "data" | "status" | "log";
|
71
76
|
export interface EventMap {
|
72
77
|
data: Payload;
|
73
78
|
status: Status;
|
79
|
+
log: LogMessage;
|
74
80
|
}
|
75
81
|
export type Event<K extends EventType> = {
|
76
82
|
[P in K]: EventMap[P] & {
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACtB,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,GAAG,EAAE,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,EAAE,GAAG,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAA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C,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/utils.d.ts
CHANGED
@@ -14,8 +14,8 @@ export declare function process_endpoint(app_reference: string, token?: `hf_${st
|
|
14
14
|
}>;
|
15
15
|
export declare function map_names_to_ids(fns: Config["dependencies"]): Record<string, number>;
|
16
16
|
export declare function discussions_enabled(space_id: string): Promise<boolean>;
|
17
|
-
export declare function get_space_hardware(space_id: string, token: `hf_${string}`): Promise<
|
18
|
-
export declare function set_space_hardware(space_id: string, new_hardware: typeof hardware_types[number], token: `hf_${string}`): Promise<
|
19
|
-
export declare function set_space_timeout(space_id: string, timeout: number, token: `hf_${string}`): Promise<
|
17
|
+
export declare function get_space_hardware(space_id: string, token: `hf_${string}`): Promise<(typeof hardware_types)[number]>;
|
18
|
+
export declare function set_space_hardware(space_id: string, new_hardware: (typeof hardware_types)[number], token: `hf_${string}`): Promise<(typeof hardware_types)[number]>;
|
19
|
+
export declare function set_space_timeout(space_id: string, timeout: number, token: `hf_${string}`): Promise<number>;
|
20
20
|
export declare const hardware_types: readonly ["cpu-basic", "cpu-upgrade", "t4-small", "t4-medium", "a10g-small", "a10g-large", "a100-large"];
|
21
21
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACrD,WAAW,EAAE,IAAI,GAAG,KAAK,CAAC;IAC1B,aAAa,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACb,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAA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M,CAAC,CAuBjB;AAED,eAAO,MAAM,cAAc,0GAQjB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gradio/client",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"description": "Gradio API client",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
@@ -19,11 +19,12 @@
|
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
21
|
"@types/ws": "^8.5.4",
|
22
|
-
"esbuild": "^0.
|
22
|
+
"esbuild": "^0.19.0"
|
23
23
|
},
|
24
24
|
"engines": {
|
25
25
|
"node": ">=18.0.0"
|
26
26
|
},
|
27
|
+
"main_changeset": true,
|
27
28
|
"scripts": {
|
28
29
|
"bundle": "vite build --ssr",
|
29
30
|
"generate_types": "tsc",
|