gradio-pr-bot commited on
Commit
d822c6a
·
verified ·
1 Parent(s): 673dd77

Upload folder using huggingface_hub

Browse files
6.2.0/client/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/client",
3
- "version": "2.0.0",
4
  "description": "Gradio API client",
5
  "type": "module",
6
  "main": "dist/index.js",
 
1
  {
2
  "name": "@gradio/client",
3
+ "version": "2.0.1",
4
  "description": "Gradio API client",
5
  "type": "module",
6
  "main": "dist/index.js",
6.2.0/client/src/types.ts CHANGED
@@ -78,7 +78,9 @@ export type SubmitFunction = (
78
  endpoint: string | number,
79
  data?: unknown[] | Record<string, unknown>,
80
  event_data?: unknown,
81
- trigger_id?: number | null
 
 
82
  ) => SubmitIterable<GradioEvent>;
83
 
84
  export type PredictFunction = (
 
78
  endpoint: string | number,
79
  data?: unknown[] | Record<string, unknown>,
80
  event_data?: unknown,
81
+ trigger_id?: number | null,
82
+ all_events?: boolean,
83
+ additional_headers?: Record<string, string>
84
  ) => SubmitIterable<GradioEvent>;
85
 
86
  export type PredictFunction = (
6.2.0/client/src/utils/submit.ts CHANGED
@@ -34,7 +34,8 @@ export function submit(
34
  data: unknown[] | Record<string, unknown> = {},
35
  event_data?: unknown,
36
  trigger_id?: number | null,
37
- all_events?: boolean
 
38
  ): SubmitIterable<GradioEvent> {
39
  try {
40
  const { token } = this.options;
@@ -55,6 +56,8 @@ export function submit(
55
  api_prefix
56
  } = this;
57
 
 
 
58
  const that = this;
59
 
60
  if (!api_info) throw new Error("No API found");
@@ -198,7 +201,8 @@ export function submit(
198
  {
199
  ...payload,
200
  session_hash
201
- }
 
202
  )
203
  .then(async ([output, status_code]: any) => {
204
  const data = output.data;
@@ -419,13 +423,14 @@ export function submit(
419
  ? post_message<Map<string, string>>("zerogpu-headers", origin)
420
  : Promise.resolve(null);
421
  const post_data_promise = zerogpu_auth_promise.then((headers) => {
 
422
  return post_data(
423
  `${config.root}${api_prefix}/${SSE_DATA_URL}?${url_params}`,
424
  {
425
  ...payload,
426
  session_hash
427
  },
428
- headers
429
  );
430
  });
431
 
 
34
  data: unknown[] | Record<string, unknown> = {},
35
  event_data?: unknown,
36
  trigger_id?: number | null,
37
+ all_events?: boolean,
38
+ additional_headers?: Record<string, string>
39
  ): SubmitIterable<GradioEvent> {
40
  try {
41
  const { token } = this.options;
 
56
  api_prefix
57
  } = this;
58
 
59
+ const addt_headers = additional_headers || { "x-gradio-user": "api" };
60
+
61
  const that = this;
62
 
63
  if (!api_info) throw new Error("No API found");
 
201
  {
202
  ...payload,
203
  session_hash
204
+ },
205
+ addt_headers
206
  )
207
  .then(async ([output, status_code]: any) => {
208
  const data = output.data;
 
423
  ? post_message<Map<string, string>>("zerogpu-headers", origin)
424
  : Promise.resolve(null);
425
  const post_data_promise = zerogpu_auth_promise.then((headers) => {
426
+ const combined_headers = { ...addt_headers, ...(headers || {}) };
427
  return post_data(
428
  `${config.root}${api_prefix}/${SSE_DATA_URL}?${url_params}`,
429
  {
430
  ...payload,
431
  session_hash
432
  },
433
+ combined_headers
434
  );
435
  });
436