diff --git a/.changeset/pretty-clowns-fall.md b/.changeset/pretty-clowns-fall.md new file mode 100644 index 0000000000000..96aed909f0ce9 --- /dev/null +++ b/.changeset/pretty-clowns-fall.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +fix:Fixes TabbedInterface bug where only first interface events get triggered diff --git a/gradio/blocks.py b/gradio/blocks.py index 4b467c0c99200..31ab22a1f1923 100644 --- a/gradio/blocks.py +++ b/gradio/blocks.py @@ -1355,6 +1355,7 @@ def render(self): if isinstance(dep.api_name, str) ] for dependency in self.fns.values(): + dependency._id += dependency_offset api_name = dependency.api_name if isinstance(api_name, str): api_name_ = utils.append_unique_suffix( diff --git a/test/test_interfaces.py b/test/test_interfaces.py index ce8727e739f07..dfae907ef19d5 100644 --- a/test/test_interfaces.py +++ b/test/test_interfaces.py @@ -263,3 +263,15 @@ def test_live_interface_sets_always_last(): assert dep["trigger_mode"] == "always_last" return raise AssertionError("No change dependency found") + + +def test_tabbed_interface_predictions(connect): + hello_world = gradio.Interface(lambda name: "Hello " + name, "text", "text") + bye_world = gradio.Interface(lambda name: "Bye " + name, "text", "text") + + demo = gradio.TabbedInterface( + [hello_world, bye_world], ["Hello World", "Bye World"] + ) + with connect(demo) as client: + assert client.predict("Emily", api_name="/predict") == "Hello Emily" + assert client.predict("Hannah", api_name="/predict") == "Hello Hannah"