@gradio/client 0.1.3 → 0.2.1
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 +24 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +507 -470
- package/dist/types.d.ts +18 -12
- 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 +4 -3
- package/src/client.ts +645 -571
- package/src/globals.d.ts +2 -4
- package/src/index.ts +7 -1
- package/src/types.ts +13 -6
- package/src/utils.ts +14 -13
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# @gradio/client
|
2
2
|
|
3
|
+
## 0.2.1
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#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)!
|
8
|
+
|
9
|
+
## 0.2.0
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
- [#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)!
|
14
|
+
- [#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)!
|
15
|
+
|
16
|
+
### Fixes
|
17
|
+
|
18
|
+
- [#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)!
|
19
|
+
|
20
|
+
## 0.1.4
|
21
|
+
|
22
|
+
### Patch Changes
|
23
|
+
|
24
|
+
- [#4717](https://github.com/gradio-app/gradio/pull/4717) [`ab5d1ea0`](https://github.com/gradio-app/gradio/commit/ab5d1ea0de87ed888779b66fd2a705583bd29e02) Thanks [@whitphx](https://github.com/whitphx)! - Fix the package description
|
25
|
+
|
3
26
|
## 0.1.3
|
4
27
|
|
5
28
|
### Patch Changes
|
@@ -34,4 +57,4 @@
|
|
34
57
|
|
35
58
|
- [#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.
|
36
59
|
|
37
|
-
- [#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.
|
60
|
+
- [#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
@@ -1,35 +1,44 @@
|
|
1
1
|
import { hardware_types } from "./utils.js";
|
2
2
|
import type { EventType, EventListener, PostResponse, UploadResponse, SpaceStatusCallback } from "./types.js";
|
3
3
|
import type { Config } from "./types.js";
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
type event = <K extends EventType>(eventType: K, listener: EventListener<K>) => SubmitReturn;
|
5
|
+
type predict = (endpoint: string | number, data?: unknown[], event_data?: unknown) => Promise<unknown>;
|
6
|
+
type client_return = {
|
7
7
|
predict: predict;
|
8
8
|
config: Config;
|
9
9
|
submit: (endpoint: string | number, data?: unknown[], event_data?: unknown) => SubmitReturn;
|
10
10
|
view_api: (c?: Config) => Promise<ApiInfo<JsApiData>>;
|
11
11
|
};
|
12
|
-
|
12
|
+
type SubmitReturn = {
|
13
13
|
on: event;
|
14
14
|
off: event;
|
15
15
|
cancel: () => Promise<void>;
|
16
16
|
destroy: () => void;
|
17
17
|
};
|
18
|
-
export declare function post_data(url: string, body: unknown, token?: `hf_${string}`): Promise<[PostResponse, number]>;
|
19
18
|
export declare let NodeBlob: any;
|
20
|
-
export declare function upload_files(root: string, files: Array<File>, token?: `hf_${string}`): Promise<UploadResponse>;
|
21
19
|
export declare function duplicate(app_reference: string, options: {
|
22
20
|
hf_token: `hf_${string}`;
|
23
21
|
private?: boolean;
|
24
22
|
status_callback: SpaceStatusCallback;
|
25
|
-
hardware?: typeof hardware_types[number];
|
23
|
+
hardware?: (typeof hardware_types)[number];
|
26
24
|
timeout?: number;
|
27
25
|
}): Promise<client_return>;
|
28
|
-
|
26
|
+
interface Client {
|
27
|
+
post_data: (url: string, body: unknown, token?: `hf_${string}`) => Promise<[PostResponse, number]>;
|
28
|
+
upload_files: (root: string, files: File[], token?: `hf_${string}`) => Promise<UploadResponse>;
|
29
|
+
client: (app_reference: string, options: {
|
30
|
+
hf_token?: `hf_${string}`;
|
31
|
+
status_callback?: SpaceStatusCallback;
|
32
|
+
normalise_files?: boolean;
|
33
|
+
}) => Promise<client_return>;
|
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: {
|
29
38
|
hf_token?: `hf_${string}`;
|
30
39
|
status_callback?: SpaceStatusCallback;
|
31
40
|
normalise_files?: boolean;
|
32
|
-
}): Promise<
|
41
|
+
}) => Promise<client_return>, handle_blob: (endpoint: string, data: unknown[], api_info: ApiInfo<JsApiData>, token?: `hf_${string}`) => Promise<unknown[]>;
|
33
42
|
interface ApiData {
|
34
43
|
label: string;
|
35
44
|
type: {
|
@@ -57,7 +66,11 @@ interface ApiInfo<T extends ApiData | JsApiData> {
|
|
57
66
|
[key: string]: EndpointInfo<T>;
|
58
67
|
};
|
59
68
|
}
|
60
|
-
export declare function
|
61
|
-
|
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
|
+
}[]>;
|
62
75
|
export {};
|
63
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,EAIb,YAAY,EACZ,cAAc,EAGd,mBAAmB,EAEnB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,
|
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,EAIb,YAAY,EACZ,cAAc,EAGd,mBAAmB,EAEnB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,KAAK,KAAK,GAAG,CAAC,CAAC,SAAS,SAAS,EAChC,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,KACtB,YAAY,CAAC;AAClB,KAAK,OAAO,GAAG,CACd,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,CAAC,EAAE,OAAO,EAAE,EAChB,UAAU,CAAC,EAAE,OAAO,KAChB,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,KAAK,aAAa,GAAG;IACpB,OAAO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,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC;CACnB;AAED,UAAU,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS;IACnD,UAAU,EAAE,CAAC,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,EAAE,CAAC;CACb;AACD,UAAU,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS;IAC9C,eAAe,EAAE;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;KAC/B,CAAC;IACF,iBAAiB,EAAE;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;KAC/B,CAAC;CACF;AAiID,wBAAsB,oBAAoB,CACzC,KAAK,KAAA,EACL,IAAI,MAAY,EAChB,IAAI,QAAK,EACT,IAAI,UAAQ,EACZ,QAAQ,MAAY,GAClB,OAAO,CACT;IACC,IAAI,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.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAW,EACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|