Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing .update and get_config, attempt 2 #5240

Merged
merged 79 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
853b354
changes
aliabid94 Aug 15, 2023
7745823
add changeset
gradio-pr-bot Aug 15, 2023
3d9bb9b
changes
aliabid94 Aug 15, 2023
e6aeba1
Merge branch 'update_attempt_2' of https://github.com/gradio-app/grad…
aliabid94 Aug 15, 2023
0a512ae
changes
aliabid94 Aug 16, 2023
ec95e4b
Update many-tips-create.md
aliabid94 Aug 16, 2023
6f52f81
Merge branch 'main' into update_attempt_2
abidlabs Aug 16, 2023
9f0a42c
notebooks
abidlabs Aug 16, 2023
967cbdc
chanegs
aliabid94 Aug 16, 2023
e0a8fb7
changes
aliabid94 Aug 16, 2023
2158698
changes
aliabid94 Aug 17, 2023
904eebd
changes
aliabid94 Aug 18, 2023
0d011bd
changes
aliabid94 Aug 18, 2023
9911390
changes
aliabid94 Aug 18, 2023
33f5922
changes
aliabid94 Aug 19, 2023
2d4b9ad
changes
aliabid94 Aug 19, 2023
f92523b
changes
aliabid94 Aug 19, 2023
3f1b544
changes
aliabid94 Aug 19, 2023
e81cc48
Merge branch 'main' into update_attempt_2
aliabid94 Aug 19, 2023
42b1f28
changes
aliabid94 Aug 25, 2023
559079d
changes
aliabid94 Aug 29, 2023
715c21a
changes
aliabid94 Aug 29, 2023
d3fdf6d
changes
aliabid94 Aug 29, 2023
f3f182c
changew
aliabid94 Aug 29, 2023
ac3aa0c
changes
aliabid94 Aug 30, 2023
036c8f5
changes
aliabid94 Aug 30, 2023
113bc7c
changes
aliabid94 Aug 30, 2023
a892bcd
changes
aliabid94 Aug 30, 2023
a282042
changes
aliabid94 Aug 30, 2023
01db73f
chanegs
aliabid94 Aug 30, 2023
0f2aefa
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Aug 30, 2023
0159898
changes
aliabid94 Sep 1, 2023
06a2027
changes
aliabid94 Sep 5, 2023
df7f322
changes
aliabid94 Sep 5, 2023
fd040e9
changes
aliabid94 Sep 5, 2023
c2ba111
changes
aliabid94 Sep 5, 2023
af00a1e
changes
aliabid94 Sep 6, 2023
2feda23
changes
aliabid94 Sep 6, 2023
2db78d0
changes
aliabid94 Sep 6, 2023
5426e9e
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Sep 8, 2023
bf37be4
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Sep 8, 2023
8061297
changes
aliabid94 Sep 8, 2023
ea73321
changes
aliabid94 Sep 8, 2023
ee2e2f5
changes
aliabid94 Sep 8, 2023
02bfde4
changes
aliabid94 Sep 8, 2023
d00dacd
changes
aliabid94 Sep 8, 2023
d36607d
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Sep 11, 2023
81fe76a
changes
aliabid94 Sep 11, 2023
0feb9de
changes
aliabid94 Sep 11, 2023
82c9405
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Sep 11, 2023
0868c25
changes
aliabid94 Sep 11, 2023
b5c50fc
Revert "changes"
aliabid94 Sep 11, 2023
9a52f9c
changes
aliabid94 Sep 11, 2023
08f7baa
changes
aliabid94 Sep 11, 2023
1f4d71b
changes
aliabid94 Sep 11, 2023
4c15cca
changes
aliabid94 Sep 11, 2023
efaddcc
changes
aliabid94 Sep 11, 2023
616f9d1
changes
aliabid94 Sep 11, 2023
c210d37
change
aliabid94 Sep 12, 2023
58075aa
changes
aliabid94 Sep 13, 2023
d2909aa
Merge remote-tracking branch 'origin' into update_attempt_2
aliabid94 Sep 14, 2023
b6486c4
changes
aliabid94 Sep 14, 2023
aa617d8
chaneges
aliabid94 Sep 14, 2023
d3317cf
Merge branch 'main' into update_attempt_2
aliabd Sep 14, 2023
ab40a47
Merge remote-tracking branch 'origin/main' into update_attempt_2
aliabid94 Sep 15, 2023
a15058c
changes
aliabid94 Sep 15, 2023
3b58172
chagnes
aliabid94 Sep 15, 2023
b0a3575
changes
aliabid94 Sep 16, 2023
46bf1a9
changes
aliabid94 Sep 18, 2023
f3b284e
changes
aliabid94 Sep 18, 2023
8cf05d9
changes
aliabid94 Sep 18, 2023
b0b55c8
changes
aliabid94 Sep 18, 2023
1fc8b24
changes
aliabid94 Sep 18, 2023
1dac13c
Merge branch 'main' into update_attempt_2
abidlabs Sep 18, 2023
e69b833
fix typing
abidlabs Sep 19, 2023
e552936
changes
aliabid94 Sep 19, 2023
5811531
Merge branch 'update_attempt_2' of https://github.com/gradio-app/grad…
aliabid94 Sep 19, 2023
1a4048d
Merge branch 'main' into update_attempt_2
abidlabs Sep 19, 2023
0a3d751
Merge branch 'main' into update_attempt_2
abidlabs Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/many-tips-create.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to make the changeset thing support multiline comments for fix + feat. I'll do that tomorrow, should be quick.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"gradio": minor
---

feat:Cleanup of .update and .get_config per component

get_config is removed, the config used is simply any attribute that is in the Block that shares a name with one of the constructor paramaters.

update is not removed for backwards compatibility, but deprecated. Instead return the component itself. Created a updateable decorator that simply checks to see if we're in an update, and if so, skips the constructor and wraps the args and kwargs in an update dictionary. easy peasy.
2 changes: 1 addition & 1 deletion demo/blocks_essay/run.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_essay"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "\n", "def change_textbox(choice):\n", " if choice == \"short\":\n", " return gr.Textbox.update(lines=2, visible=True)\n", " elif choice == \"long\":\n", " return gr.Textbox.update(lines=8, visible=True)\n", " else:\n", " return gr.Textbox.update(visible=False)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " radio = gr.Radio(\n", " [\"short\", \"long\", \"none\"], label=\"What kind of essay would you like to write?\"\n", " )\n", " text = gr.Textbox(lines=2, interactive=True).style(show_copy_button=True)\n", "\n", " radio.change(fn=change_textbox, inputs=radio, outputs=text)\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_essay"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "\n", "def change_textbox(choice):\n", " if choice == \"short\":\n", " return gr.Textbox(lines=2, visible=True)\n", " elif choice == \"long\":\n", " return gr.Textbox(lines=8, visible=True, value=\"Lorem ipsum dolor sit amet\")\n", " else:\n", " return gr.Textbox(visible=False)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " radio = gr.Radio(\n", " [\"short\", \"long\", \"none\"], label=\"What kind of essay would you like to write?\"\n", " )\n", " text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)\n", " radio.change(fn=change_textbox, inputs=radio, outputs=text)\n", "\n", " with gr.Row():\n", " num = gr.Number(minimum=0, maximum=100, label=\"input\")\n", " out = gr.Number(label=\"output\")\n", " min = gr.Slider(0, 100, 0, label=\"min\")\n", " max = gr.Slider(0, 100, 100, label=\"max\")\n", "\n", " def reset_bounds(min, max):\n", " return gr.Number(minimum=min, maximum=max)\n", " \n", " min.change(reset_bounds, [min, max], outputs=num)\n", " max.change(reset_bounds, [min, max], outputs=num)\n", " num.submit(lambda x:x, num, out)\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
22 changes: 17 additions & 5 deletions demo/blocks_essay/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@

def change_textbox(choice):
if choice == "short":
return gr.Textbox.update(lines=2, visible=True)
return gr.Textbox(lines=2, visible=True)
elif choice == "long":
return gr.Textbox.update(lines=8, visible=True)
return gr.Textbox(lines=8, visible=True, value="Lorem ipsum dolor sit amet")
else:
return gr.Textbox.update(visible=False)
return gr.Textbox(visible=False)


with gr.Blocks() as demo:
radio = gr.Radio(
["short", "long", "none"], label="What kind of essay would you like to write?"
)
text = gr.Textbox(lines=2, interactive=True).style(show_copy_button=True)

text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)
radio.change(fn=change_textbox, inputs=radio, outputs=text)

with gr.Row():
num = gr.Number(minimum=0, maximum=100, label="input")
out = gr.Number(label="output")
min = gr.Slider(0, 100, 0, label="min")
max = gr.Slider(0, 100, 100, label="max")

def reset_bounds(min, max):
return gr.Number(minimum=min, maximum=max)

min.change(reset_bounds, [min, max], outputs=num)
max.change(reset_bounds, [min, max], outputs=num)
num.submit(lambda x:x, num, out)


if __name__ == "__main__":
demo.launch()
2 changes: 1 addition & 1 deletion demo/chatbot_multimodal/run.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.\n", "\n", "def add_text(history, text):\n", " history = history + [(text, None)]\n", " return history, gr.update(value=\"\", interactive=False)\n", "\n", "\n", "def add_file(history, file):\n", " history = history + [((file.name,), None)]\n", " return history\n", "\n", "\n", "def bot(history):\n", " response = \"**That's cool!**\"\n", " history[-1][1] = \"\"\n", " for character in response:\n", " history[-1][1] += character\n", " time.sleep(0.05)\n", " yield history\n", "\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot([], elem_id=\"chatbot\").style(height=750)\n", "\n", " with gr.Row():\n", " with gr.Column(scale=0.85):\n", " txt = gr.Textbox(\n", " show_label=False,\n", " placeholder=\"Enter text and press enter, or upload an image\",\n", " ).style(container=False)\n", " with gr.Column(scale=0.15, min_width=0):\n", " btn = gr.UploadButton(\"\ud83d\udcc1\", file_types=[\"image\", \"video\", \"audio\"])\n", "\n", " txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", " txt_msg.then(lambda: gr.update(interactive=True), None, [txt], queue=False)\n", " file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", "\n", "demo.queue()\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.\n", "\n", "def add_text(history, text):\n", " history = history + [(text, None)]\n", " return history, gr.update(value=\"\", interactive=False)\n", "\n", "\n", "def add_file(history, file):\n", " history = history + [((file.name,), None)]\n", " return history\n", "\n", "\n", "def bot(history):\n", " response = \"**That's cool!**\"\n", " history[-1][1] = \"\"\n", " for character in response:\n", " history[-1][1] += character\n", " time.sleep(0.05)\n", " yield history\n", "\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot([], elem_id=\"chatbot\", height=750)\n", "\n", " with gr.Row():\n", " with gr.Column(scale=0.85):\n", " txt = gr.Textbox(\n", " show_label=False,\n", " placeholder=\"Enter text and press enter, or upload an image\",\n", " container=False)\n", " with gr.Column(scale=0.15, min_width=0):\n", " btn = gr.UploadButton(\"\ud83d\udcc1\", file_types=[\"image\", \"video\", \"audio\"])\n", "\n", " txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", " txt_msg.then(lambda: gr.update(interactive=True), None, [txt], queue=False)\n", " file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", "\n", "demo.queue()\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
43 changes: 37 additions & 6 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import webbrowser
from abc import abstractmethod
from collections import defaultdict
from functools import wraps
from pathlib import Path
from types import ModuleType
from typing import TYPE_CHECKING, Any, AsyncIterator, Callable, Literal, cast
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(
self._skip_init_processing = _skip_init_processing
self.parent: BlockContext | None = None
self.is_rendered: bool = False
self.update_config: dict

if render:
self.render()
Expand Down Expand Up @@ -307,12 +309,13 @@ def set_event_trigger(
return dependency, len(Context.root_block.dependencies) - 1

def get_config(self):
return {
"visible": self.visible,
"elem_id": self.elem_id,
"elem_classes": self.elem_classes,
"root_url": self.root_url,
}
config = {}
signature = inspect.signature(self.__class__.__init__)
for parameter in signature.parameters.values():
if hasattr(self, parameter.name):
value = getattr(self, parameter.name)
config[parameter.name] = value
return {**config, "root_url": self.root_url, "name": self.get_block_name()}

@staticmethod
@abstractmethod
Expand Down Expand Up @@ -1327,6 +1330,8 @@ def postprocess_data(
output.append(None)
else:
prediction_value = predictions[i]
if isinstance(prediction_value, Block):
prediction_value = prediction_value.update_config
if utils.is_update(prediction_value):
assert isinstance(prediction_value, dict)
prediction_value = postprocess_update_dict(
Expand Down Expand Up @@ -2241,3 +2246,29 @@ def queue_enabled_for_fn(self, fn_index: int):
if self.dependencies[fn_index]["queue"] is None:
return self.enable_queue
return self.dependencies[fn_index]["queue"]


def is_update():
from gradio import context

return hasattr(context.thread_data, "blocks")


def updateable(fn):
Copy link
Collaborator

@freddyaboulton freddyaboulton Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can automatically wrap the init with updateable in a metaclass so that custom component authors don't even have to worry about this when creating their own components 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was trying to think how to do this. Not familiar with metaclasses, will take a look!

@wraps(fn)
def wrapper(*args, **kwargs):
if is_update():
fn_args = inspect.getfullargspec(fn).args
self = args[0]
for i, arg in enumerate(args):
if i == 0: # skip self
continue
arg_name = fn_args[i]
kwargs[arg_name] = arg
kwargs["__type__"] = "update"
self.update_config = kwargs
return None
else:
return fn(*args, **kwargs)

return wrapper
13 changes: 2 additions & 11 deletions gradio/components/annotated_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from PIL import Image as _Image # using _ to minimize namespace pollution

from gradio import utils
from gradio.blocks import updateable
from gradio.components.base import IOComponent, _Keywords
from gradio.deprecation import warn_style_method_deprecation
from gradio.events import (
Expand All @@ -32,6 +33,7 @@ class AnnotatedImage(Selectable, IOComponent, JSONSerializable):
Demos: image_segmentation
"""

@updateable
def __init__(
self,
value: tuple[
Expand Down Expand Up @@ -97,17 +99,6 @@ def __init__(
**kwargs,
)

def get_config(self):
return {
"show_legend": self.show_legend,
"value": self.value,
"height": self.height,
"width": self.width,
"color_map": self.color_map,
"selectable": self.selectable,
**IOComponent.get_config(self),
}

@staticmethod
def update(
value: tuple[
Expand Down
14 changes: 2 additions & 12 deletions gradio/components/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from gradio_client.serializing import FileSerializable

from gradio import processing_utils, utils
from gradio.blocks import updateable
from gradio.components.base import IOComponent, _Keywords
from gradio.events import (
Changeable,
Expand Down Expand Up @@ -51,6 +52,7 @@ class Audio(
Guides: real-time-speech-recognition
"""

@updateable
def __init__(
self,
value: str | Path | tuple[int, np.ndarray] | Callable | None = None,
Expand Down Expand Up @@ -141,18 +143,6 @@ def __init__(
)
TokenInterpretable.__init__(self)

def get_config(self):
return {
"source": self.source,
"value": self.value,
"streaming": self.streaming,
"autoplay": self.autoplay,
"show_download_button": self.show_download_button,
"show_share_button": self.show_share_button,
"show_edit_button": self.show_edit_button,
**IOComponent.get_config(self),
}

def example_inputs(self) -> dict[str, Any]:
return {
"raw": {"is_file": False, "data": media_data.BASE64_AUDIO},
Expand Down
7 changes: 2 additions & 5 deletions gradio/components/bar_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
from gradio_client.documentation import document, set_documentation_group

from gradio.blocks import updateable
from gradio.components.base import _Keywords
from gradio.components.plot import AltairPlot, Plot

Expand All @@ -25,6 +26,7 @@ class BarPlot(Plot):
Demos: bar_plot, chicago-bikeshare-dashboard
"""

@updateable
def __init__(
self,
value: pd.DataFrame | Callable | None = None,
Expand Down Expand Up @@ -125,11 +127,6 @@ def __init__(
every=every,
)

def get_config(self):
config = super().get_config()
config["caption"] = self.caption
return config

def get_block_name(self) -> str:
return "plot"

Expand Down
23 changes: 0 additions & 23 deletions gradio/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ def __str__(self):
def __repr__(self):
return f"{self.get_block_name()}"

def get_config(self):
"""
:return: a dictionary with context variables for the javascript file associated with the context
"""
return {
"name": self.get_block_name(),
**super().get_config(),
}

def preprocess(self, x: Any) -> Any:
"""
Any preprocessing needed to be performed on function input.
Expand Down Expand Up @@ -335,20 +326,6 @@ def file_bytes_to_file(self, data: bytes, dir: str, file_name: str):
path.write_bytes(data)
return path

def get_config(self):
config = {
"label": self.label,
"show_label": self.show_label,
"container": self.container,
"scale": self.scale,
"min_width": self.min_width,
"interactive": self.interactive,
**super().get_config(),
}
if self.info:
config["info"] = self.info
return config

@staticmethod
def get_load_fn_and_initial_value(value):
if callable(value):
Expand Down
17 changes: 3 additions & 14 deletions gradio/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from gradio_client.documentation import document, set_documentation_group
from gradio_client.serializing import StringSerializable

from gradio.components.base import Component, IOComponent, _Keywords
from gradio.blocks import updateable
from gradio.components.base import IOComponent, _Keywords
from gradio.deprecation import warn_deprecation, warn_style_method_deprecation
from gradio.events import Clickable

Expand All @@ -24,6 +25,7 @@ class Button(Clickable, IOComponent, StringSerializable):
Demos: blocks_inputs, blocks_kinematics
"""

@updateable
def __init__(
self,
value: str | Callable = "Run",
Expand Down Expand Up @@ -75,19 +77,6 @@ def __init__(

self.link = link

def get_config(self):
return {
"value": self.value,
"variant": self.variant,
"size": self.size,
"icon": self.icon,
"link": self.link,
"interactive": self.interactive,
"scale": self.scale,
"min_width": self.min_width,
**Component.get_config(self),
}

@staticmethod
def update(
value: str | Literal[_Keywords.NO_VALUE] | None = _Keywords.NO_VALUE,
Expand Down
2 changes: 2 additions & 0 deletions gradio/components/carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from gradio_client.serializing import SimpleSerializable

from gradio.blocks import updateable
from gradio.components.base import IOComponent
from gradio.events import Changeable

Expand All @@ -11,6 +12,7 @@ class Carousel(IOComponent, Changeable, SimpleSerializable):
Deprecated Component
"""

@updateable
def __init__(
self,
*args,
Expand Down
14 changes: 2 additions & 12 deletions gradio/components/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from gradio_client.serializing import JSONSerializable

from gradio import utils
from gradio.blocks import updateable
from gradio.components.base import IOComponent, _Keywords
from gradio.deprecation import warn_deprecation, warn_style_method_deprecation
from gradio.events import (
Expand All @@ -33,6 +34,7 @@ class Chatbot(Changeable, Selectable, IOComponent, JSONSerializable):
Guides: creating-a-chatbot
"""

@updateable
def __init__(
self,
value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
Expand Down Expand Up @@ -110,18 +112,6 @@ def __init__(
**kwargs,
)

def get_config(self):
return {
"value": self.value,
"latex_delimiters": self.latex_delimiters,
"selectable": self.selectable,
"height": self.height,
"show_share_button": self.show_share_button,
"rtl": self.rtl,
"show_copy_button": self.show_copy_button,
**IOComponent.get_config(self),
}

@staticmethod
def update(
value: list[list[str | tuple[str] | tuple[str, str] | None]]
Expand Down
8 changes: 2 additions & 6 deletions gradio/components/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from gradio_client.documentation import document, set_documentation_group
from gradio_client.serializing import BooleanSerializable

from gradio.blocks import updateable
from gradio.components.base import FormComponent, IOComponent, _Keywords
from gradio.events import Changeable, EventListenerMethod, Inputable, Selectable
from gradio.interpretation import NeighborInterpretable
Expand All @@ -33,6 +34,7 @@ class Checkbox(
Demos: sentence_builder, titanic_survival
"""

@updateable
def __init__(
self,
value: bool | Callable = False,
Expand Down Expand Up @@ -89,12 +91,6 @@ def __init__(
)
NeighborInterpretable.__init__(self)

def get_config(self):
return {
"value": self.value,
**IOComponent.get_config(self),
}

@staticmethod
def update(
value: bool | Literal[_Keywords.NO_VALUE] | None = _Keywords.NO_VALUE,
Expand Down
Loading