From 3850f13624fed5a002da14a2b2e3be95f59ca160 Mon Sep 17 00:00:00 2001 From: Andy Salerno Date: Tue, 11 Apr 2023 20:15:12 -0700 Subject: [PATCH] Change fn_index in api_example_stream (#904) --- api-example-stream.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api-example-stream.py b/api-example-stream.py index 17de4c28..0b58b094 100644 --- a/api-example-stream.py +++ b/api-example-stream.py @@ -12,6 +12,11 @@ import string import websockets +# Note, Gradio may pick a different fn value as the definition of the Gradio app changes. +# You can always launch the web UI and inspect the websocket stream using your browser's dev tools +# to determine what value Gradio expects here. +GRADIO_FN = 8 + def random_hash(): letters = string.ascii_lowercase + string.digits @@ -47,14 +52,14 @@ async def run(context): case "send_hash": await websocket.send(json.dumps({ "session_hash": session, - "fn_index": 12 + "fn_index": GRADIO_FN })) case "estimation": pass case "send_data": await websocket.send(json.dumps({ "session_hash": session, - "fn_index": 12, + "fn_index": GRADIO_FN, "data": [ payload ]