Fix gr.load() so that it works with the SSE v1 protocol (#6810)

* fix for gr.load()

* add changeset

* fix

* add test

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2023-12-15 12:35:46 -08:00 committed by GitHub
parent 6b130e26b9
commit 526fb6c446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
fix:Fix `gr.load()` so that it works with the SSE v1 protocol

View File

@ -538,9 +538,7 @@ def from_spaces_blocks(space: str, hf_token: str | None) -> Blocks:
predict_fns = []
for fn_index, endpoint in enumerate(client.endpoints):
assert isinstance(endpoint, Endpoint)
helper = None
if endpoint.protocol in ("ws", "sse"):
helper = client.new_helper(fn_index)
helper = client.new_helper(fn_index)
predict_fns.append(endpoint.make_end_to_end_fn(helper))
return gradio.Blocks.from_config(client.config, predict_fns, client.src)

View File

@ -340,6 +340,18 @@ class TestLoadInterface:
)
assert r.status_code == 200
def test_private_space_v4_sse_v1(self):
io = gr.load(
"spaces/gradio-tests/not-actually-private-spacev4-sse-v1",
hf_token=HfFolder.get_token(),
)
try:
output = io("abc")
assert output == "abc"
assert io.theme.name == "gradio/monochrome"
except TooManyRequestsError:
pass
class TestLoadInterfaceWithExamples:
def test_interface_load_examples(self, tmp_path):