-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0e93d7
commit 3f07be9
Showing
164 changed files
with
1,571 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "gradio", | ||
"version": "4.42.0", | ||
"version": "4.43.0", | ||
"description": "", | ||
"python": "true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { ApiData, ApiInfo, ClientOptions, Config, DuplicateOptions, EndpointInfo, JsApiData, PredictReturn, SpaceStatus, Status, UploadResponse, SubmitIterable, GradioEvent } from "./types"; | ||
import { FileData } from "./upload"; | ||
export declare class Client { | ||
app_reference: string; | ||
options: ClientOptions; | ||
config: Config | undefined; | ||
api_info: ApiInfo<JsApiData> | undefined; | ||
api_map: Record<string, number>; | ||
session_hash: string; | ||
jwt: string | false; | ||
last_status: Record<string, Status["stage"]>; | ||
private cookies; | ||
stream_status: { | ||
open: boolean; | ||
}; | ||
pending_stream_messages: Record<string, any[][]>; | ||
pending_diff_streams: Record<string, any[][]>; | ||
event_callbacks: Record<string, (data?: unknown) => Promise<void>>; | ||
unclosed_events: Set<string>; | ||
heartbeat_event: EventSource | null; | ||
abort_controller: AbortController | null; | ||
stream_instance: EventSource | null; | ||
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; | ||
stream(url: URL): EventSource; | ||
view_api: () => Promise<ApiInfo<JsApiData>>; | ||
upload_files: (root_url: string, files: (Blob | File)[], upload_id?: string) => Promise<UploadResponse>; | ||
upload: (file_data: FileData[], root_url: string, upload_id?: string, max_file_size?: number) => Promise<(FileData | null)[] | null>; | ||
handle_blob: (endpoint: string, data: unknown[], endpoint_info: EndpointInfo<ApiData | JsApiData>) => Promise<unknown[]>; | ||
post_data: (url: string, body: unknown, additional_headers?: any) => Promise<unknown[]>; | ||
submit: (endpoint: string | number, data: unknown[] | Record<string, unknown> | undefined, event_data?: unknown, trigger_id?: number | null, all_events?: boolean) => SubmitIterable<GradioEvent>; | ||
predict: (endpoint: string | number, data: unknown[] | Record<string, unknown> | undefined, event_data?: unknown) => Promise<PredictReturn>; | ||
open_stream: () => Promise<void>; | ||
private resolve_config; | ||
private resolve_cookies; | ||
constructor(app_reference: string, options?: ClientOptions); | ||
private init; | ||
_resolve_hearbeat(_config: Config): Promise<void>; | ||
static connect(app_reference: string, options?: ClientOptions): Promise<Client>; | ||
close(): void; | ||
static duplicate(app_reference: string, options?: DuplicateOptions): Promise<Client>; | ||
private _resolve_config; | ||
private config_success; | ||
handle_space_success(status: SpaceStatus): Promise<Config | void>; | ||
component_server(component_id: number, fn_name: string, data: unknown[] | { | ||
binary: boolean; | ||
data: Record<string, any>; | ||
}): Promise<unknown>; | ||
set_cookies(raw_cookies: string): void; | ||
private prepare_return_obj; | ||
} | ||
/** | ||
* @deprecated This method will be removed in v1.0. Use `Client.connect()` instead. | ||
* Creates a client instance for interacting with Gradio apps. | ||
* | ||
* @param {string} app_reference - The reference or URL to a Gradio space or app. | ||
* @param {ClientOptions} options - Configuration options for the client. | ||
* @returns {Promise<Client>} A promise that resolves to a `Client` instance. | ||
*/ | ||
export declare function client(app_reference: string, options?: ClientOptions): Promise<Client>; | ||
/** | ||
* @deprecated This method will be removed in v1.0. Use `Client.duplicate()` instead. | ||
* Creates a duplicate of a space and returns a client instance for the duplicated space. | ||
* | ||
* @param {string} app_reference - The reference or URL to a Gradio space or app to duplicate. | ||
* @param {DuplicateOptions} options - Configuration options for the client. | ||
* @returns {Promise<Client>} A promise that resolves to a `Client` instance. | ||
*/ | ||
export declare function duplicate_space(app_reference: string, options: DuplicateOptions): Promise<Client>; | ||
export type ClientInstance = Client; |
29 changes: 29 additions & 0 deletions
29
home/runner/work/gradio/gradio/client/js/src/constants.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export declare const HOST_URL = "host"; | ||
export declare const API_URL = "api/predict/"; | ||
export declare const SSE_URL_V0 = "queue/join"; | ||
export declare const SSE_DATA_URL_V0 = "queue/data"; | ||
export declare const SSE_URL = "queue/data"; | ||
export declare const SSE_DATA_URL = "queue/join"; | ||
export declare const UPLOAD_URL = "upload"; | ||
export declare const LOGIN_URL = "login"; | ||
export declare const CONFIG_URL = "config"; | ||
export declare const API_INFO_URL = "info"; | ||
export declare const RUNTIME_URL = "runtime"; | ||
export declare const SLEEPTIME_URL = "sleeptime"; | ||
export declare const RAW_API_INFO_URL = "info?serialize=False"; | ||
export declare const SPACE_FETCHER_URL = "https://gradio-space-api-fetcher-v2.hf.space/api"; | ||
export declare const RESET_URL = "reset"; | ||
export declare const SPACE_URL = "https://hf.space/{}"; | ||
export declare const QUEUE_FULL_MSG = "This application is currently busy. Please try again. "; | ||
export declare const BROKEN_CONNECTION_MSG = "Connection errored out. "; | ||
export declare const CONFIG_ERROR_MSG = "Could not resolve app config. "; | ||
export declare const SPACE_STATUS_ERROR_MSG = "Could not get space status. "; | ||
export declare const API_INFO_ERROR_MSG = "Could not get API info. "; | ||
export declare const SPACE_METADATA_ERROR_MSG = "Space metadata could not be loaded. "; | ||
export declare const INVALID_URL_MSG = "Invalid URL. A full URL path is required."; | ||
export declare const UNAUTHORIZED_MSG = "Not authorized to access this space. "; | ||
export declare const INVALID_CREDENTIALS_MSG = "Invalid credentials. Could not login. "; | ||
export declare const MISSING_CREDENTIALS_MSG = "Login credentials are required to access this space."; | ||
export declare const NODEJS_FS_ERROR_MSG = "File system access is only available in Node.js environments"; | ||
export declare const ROOT_URL_ERROR_MSG = "Root URL not found in client config"; | ||
export declare const FILE_PROCESSING_ERROR_MSG = "Error uploading file"; |
46 changes: 46 additions & 0 deletions
46
home/runner/work/gradio/gradio/client/js/src/helpers/api_info.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { ApiData, ApiInfo, Config, JsApiData, EndpointInfo, Status } from "../types"; | ||
export declare const RE_SPACE_NAME: RegExp; | ||
export declare const RE_SPACE_DOMAIN: RegExp; | ||
export declare function process_endpoint(app_reference: string, hf_token?: `hf_${string}`): Promise<{ | ||
space_id: string | false; | ||
host: string; | ||
ws_protocol: "ws" | "wss"; | ||
http_protocol: "http:" | "https:"; | ||
}>; | ||
export declare const join_urls: (...urls: string[]) => string; | ||
export declare function transform_api_info(api_info: ApiInfo<ApiData>, config: Config, api_map: Record<string, number>): ApiInfo<JsApiData>; | ||
export declare function get_type(type: { | ||
type: any; | ||
description: string; | ||
}, component: string, serializer: string, signature_type: "return" | "parameter"): string | undefined; | ||
export declare function get_description(type: { | ||
type: any; | ||
description: string; | ||
}, serializer: string): string; | ||
export declare function handle_message(data: any, last_status: Status["stage"]): { | ||
type: "hash" | "data" | "update" | "complete" | "generating" | "log" | "none" | "heartbeat" | "unexpected_error"; | ||
data?: any; | ||
status?: Status; | ||
}; | ||
/** | ||
* Maps the provided `data` to the parameters defined by the `/info` endpoint response. | ||
* This allows us to support both positional and keyword arguments passed to the client | ||
* and ensures that all parameters are either directly provided or have default values assigned. | ||
* | ||
* @param {unknown[] | Record<string, unknown>} data - The input data for the function, | ||
* which can be either an array of values for positional arguments or an object | ||
* with key-value pairs for keyword arguments. | ||
* @param {JsApiData[]} parameters - Array of parameter descriptions retrieved from the | ||
* `/info` endpoint. | ||
* | ||
* @returns {unknown[]} - Returns an array of resolved data where each element corresponds | ||
* to the expected parameter from the API. The `parameter_default` value is used where | ||
* a value is not provided for a parameter, and optional parameters without defaults are | ||
* set to `undefined`. | ||
* | ||
* @throws {Error} - Throws an error: | ||
* - If more arguments are provided than are defined in the parameters. | ||
* * - If no parameter value is provided for a required parameter and no default value is defined. | ||
* - If an argument is provided that does not match any defined parameter. | ||
*/ | ||
export declare const map_data_to_params: (data: (unknown[] | Record<string, unknown>) | undefined, endpoint_info: EndpointInfo<JsApiData | ApiData>) => unknown[]; |
20 changes: 20 additions & 0 deletions
20
home/runner/work/gradio/gradio/client/js/src/helpers/data.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type ApiData, type BlobRef, type Config, type EndpointInfo, type JsApiData, type DataType, Command, type Dependency, type ComponentMeta } from "../types"; | ||
import { FileData } from "../upload"; | ||
export declare function update_object(object: { | ||
[x: string]: any; | ||
}, newValue: any, stack: (string | number)[]): void; | ||
export declare function walk_and_store_blobs(data: DataType, type?: string | undefined, path?: string[], root?: boolean, endpoint_info?: EndpointInfo<ApiData | JsApiData> | undefined): Promise<BlobRef[]>; | ||
export declare function skip_queue(id: number, config: Config): boolean; | ||
export declare function post_message<Res = any>(message: any, origin: string): Promise<Res>; | ||
export declare function handle_file(file_or_url: File | string | Blob | Buffer): FileData | Blob | Command; | ||
/** | ||
* Handles the payload by filtering out state inputs and returning an array of resolved payload values. | ||
* We send null values for state inputs to the server, but we don't want to include them in the resolved payload. | ||
* | ||
* @param resolved_payload - The resolved payload values received from the client or the server | ||
* @param dependency - The dependency object. | ||
* @param components - The array of component metadata. | ||
* @param with_null_state - Optional. Specifies whether to include null values for state inputs. Default is false. | ||
* @returns An array of resolved payload values, filtered based on the dependency and component metadata. | ||
*/ | ||
export declare function handle_payload(resolved_payload: unknown[], dependency: Dependency, components: ComponentMeta[], type: "input" | "output", with_null_state?: boolean): unknown[]; |
24 changes: 24 additions & 0 deletions
24
home/runner/work/gradio/gradio/client/js/src/helpers/init_helpers.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Config } from "../types"; | ||
import { Client } from ".."; | ||
/** | ||
* This function is used to resolve the URL for making requests when the app has a root path. | ||
* The root path could be a path suffix like "/app" which is appended to the end of the base URL. Or | ||
* it could be a full URL like "https://abidlabs-test-client-replica--gqf2x.hf.space" which is used when hosting | ||
* Gradio apps on Hugging Face Spaces. | ||
* @param {string} base_url The base URL at which the Gradio server is hosted | ||
* @param {string} root_path The root path, which could be a path suffix (e.g. mounted in FastAPI app) or a full URL (e.g. hosted on Hugging Face Spaces) | ||
* @param {boolean} prioritize_base Whether to prioritize the base URL over the root path. This is used when both the base path and root paths are full URLs. For example, for fetching files the root path should be prioritized, but for making requests, the base URL should be prioritized. | ||
* @returns {string} the resolved URL | ||
*/ | ||
export declare function resolve_root(base_url: string, root_path: string, prioritize_base: boolean): string; | ||
export declare function get_jwt(space: string, token: `hf_${string}`, cookies?: string | null): Promise<string | false>; | ||
export declare function map_names_to_ids(fns: Config["dependencies"]): Record<string, number>; | ||
export declare function resolve_config(this: Client, endpoint: string): Promise<Config | undefined>; | ||
export declare function resolve_cookies(this: Client): Promise<void>; | ||
export declare function get_cookie_header(http_protocol: string, host: string, auth: [string, string], _fetch: typeof fetch, hf_token?: `hf_${string}`): Promise<string | null>; | ||
export declare function determine_protocol(endpoint: string): { | ||
ws_protocol: "ws" | "wss"; | ||
http_protocol: "http:" | "https:"; | ||
host: string; | ||
}; | ||
export declare const parse_and_set_cookies: (cookie_header: string) => string[]; |
7 changes: 7 additions & 0 deletions
7
home/runner/work/gradio/gradio/client/js/src/helpers/spaces.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { SpaceStatusCallback } from "../types"; | ||
export declare function check_space_status(id: string, type: "subdomain" | "space_name", status_callback: SpaceStatusCallback): Promise<void>; | ||
export declare const check_and_wake_space: (space_id: string, status_callback: SpaceStatusCallback) => Promise<void>; | ||
export declare function discussions_enabled(space_id: string): Promise<boolean>; | ||
export declare function get_space_hardware(space_id: string, hf_token?: `hf_${string}` | undefined): Promise<(typeof hardware_types)[number]>; | ||
export declare function set_space_timeout(space_id: string, timeout: number, hf_token?: `hf_${string}`): Promise<any>; | ||
export declare const hardware_types: readonly ["cpu-basic", "cpu-upgrade", "cpu-xl", "t4-small", "t4-medium", "a10g-small", "a10g-large", "a10g-largex2", "a10g-largex4", "a100-large", "zero-a10g", "h100", "h100x8"]; |
Oops, something went wrong.