Ensure all status are reported internally when calling predict (#8485)

* fix param name

* format

* fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
pngwn 2024-06-06 15:57:00 +01:00 committed by GitHub
parent c79639448c
commit f8ebacecce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---
feat:Ensure all status are reported internally when calling `predict`

View File

@ -102,7 +102,8 @@ export class Client {
endpoint: string | number,
data: unknown[] | Record<string, unknown>,
event_data?: unknown,
trigger_id?: number | null
trigger_id?: number | null,
all_events?: boolean
) => SubmitIterable<GradioEvent>;
predict: (
endpoint: string | number,

View File

@ -30,7 +30,7 @@ export async function predict(
}
return new Promise(async (resolve, reject) => {
const app = this.submit(endpoint, data);
const app = this.submit(endpoint, data, null, null, true);
let result: unknown;
for await (const message of app) {

View File

@ -28,7 +28,8 @@ export function submit(
endpoint: string | number,
data: unknown[] | Record<string, unknown>,
event_data?: unknown,
trigger_id?: number | null
trigger_id?: number | null,
all_events?: boolean
): SubmitIterable<GradioEvent> {
try {
const { hf_token } = this.options;
@ -87,7 +88,7 @@ export function submit(
// event subscription methods
function fire_event(event: GradioEvent): void {
if (events_to_publish[event.type]) {
if (all_events || events_to_publish[event.type]) {
push_event(event);
}
}