gradio/client/js
space-nuko 5a7610950e
Fix sketch tool gr.Image not filling up the entire component size (#3649)
* Fix sketch tool `gr.Image` not filling up the entire component size

* Update changelog

* version

* version

* changes

* changes

* Update js/atoms/src/Block.svelte

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: aliabid94 <aabid94@gmail.com>
2023-04-10 14:27:02 -07:00
..
src Fix sketch tool gr.Image not filling up the entire component size (#3649) 2023-04-10 14:27:02 -07:00
package.json node support for js client (#3692) 2023-04-03 14:33:01 +01:00
README.md move files (#3605) 2023-03-27 16:12:58 -07:00
tsconfig.json node support for js client (#3692) 2023-04-03 14:33:01 +01:00
vite.config.js node support for js client (#3692) 2023-04-03 14:33:01 +01:00

@gradio/client

A javascript client to call Gradio APIs.

install it

pnpm add @gradio/client

usage

import { client } from "@gradio/client";

const app = client();

const prediction = app.predict(endpoint, payload);

// listen for predictions
prediction.on("data", (event: { data: Array<unknown>; type: "data" }) => {});

// listen for status updates
prediction.on("status", (event: { data: Status; type: "data" }) => {});

interface Status {
	status: "pending" | "error" | "complete" | "generating";
	size: number;
	position?: number;
	eta?: number;
	message?: string;
	progress?: Array<{
		progress: number | null;
		index: number | null;
		length: number | null;
		unit: string | null;
		desc: string | null;
	}>;
}

// stop listening
prediction.off("data");

// cancel a prediction if it is a generator
prediction.cancel();

// chainable
const prediction_two = app
	.predict(endpoint, payload)
	.on("data", data_callback)
	.on("status", status_callback);