Skip to content

Commit 8ce8063

Browse files
committed
refactor(antdx): components migration
1 parent 1cd2ed1 commit 8ce8063

File tree

278 files changed

+1990
-1291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+1990
-1291
lines changed

backend/modelscope_studio/components/antdx/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
from .prompts.item import AntdXPromptsItem as PromptsItem
2222
from .sender import AntdXSender as Sender
2323
from .sender.header import AntdXSenderHeader as SenderHeader
24+
from .sender.switch import AntdXSenderSwitch as SenderSwitch
2425
from .suggestion import AntdXSuggestion as Suggestion
2526
from .suggestion.item import AntdXSuggestionItem as SuggestionItem
2627
from .thought_chain import AntdXThoughtChain as ThoughtChain
2728
from .thought_chain.item import AntdXThoughtChainItem as ThoughtChainItem
29+
from .thought_chain.thought_chain_item import AntdXThoughtChainThoughtChainItem as ThoughtChainThoughtChainItem
2830
from .welcome import AntdXWelcome as Welcome
2931
from .x_provider import AntdXXProvider as XProvider

backend/modelscope_studio/components/antdx/components.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
from .prompts.item import AntdXPromptsItem
2121
from .sender import AntdXSender
2222
from .sender.header import AntdXSenderHeader
23+
from .sender.switch import AntdXSenderSwitch
2324
from .suggestion import AntdXSuggestion
2425
from .suggestion.item import AntdXSuggestionItem
2526
from .thought_chain import AntdXThoughtChain
2627
from .thought_chain.item import AntdXThoughtChainItem
28+
from .thought_chain.thought_chain_item import AntdXThoughtChainThoughtChainItem
2729
from .welcome import AntdXWelcome
2830
from .x_provider import AntdXXProvider

backend/modelscope_studio/components/antdx/conversations/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ class AntdXConversations(ModelScopeLayoutComponent):
3232
EventListener("menu_select",
3333
callback=lambda block: block._internal.update(
3434
bind_menu_select_event=True)),
35+
EventListener("groupable_expand",
36+
callback=lambda block: block._internal.update(
37+
bind_groupable_expand_event=True)),
38+
EventListener("creation_click",
39+
callback=lambda block: block._internal.update(
40+
bind_creation_click_event=True)),
3541
]
3642

3743
# supported slots
3844
SLOTS = [
3945
'menu.expandIcon', 'menu.overflowedIndicator', 'menu.trigger',
40-
'groupable.title', 'items'
46+
'groupable.label', 'items', 'creation.icon', 'creation.label'
4147
]
4248

4349
def __init__(
@@ -49,8 +55,10 @@ def __init__(
4955
items: list[dict] | None = None,
5056
menu: str | dict | None = None,
5157
groupable: bool | dict | None = None,
52-
styles: dict | str | None= None,
53-
class_names: dict | str | None= None,
58+
shortcut_keys: dict | None = None,
59+
creation: dict | None = None,
60+
styles: dict | str | None = None,
61+
class_names: dict | str | None = None,
5462
root_class_name: str | None = None,
5563
as_item: str | None = None,
5664
_internal: None = None,
@@ -74,6 +82,8 @@ def __init__(
7482
self.items = items
7583
self.menu = menu
7684
self.groupable = groupable
85+
self.shortcut_keys = shortcut_keys
86+
self.creation = creation
7787
self.styles = styles
7888
self.class_names = class_names
7989
self.root_class_name = root_class_name

backend/modelscope_studio/components/antdx/conversations/item/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import Any, Literal
44

55
from .....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
66

@@ -21,13 +21,14 @@ class AntdXConversationsItem(ModelScopeLayoutComponent):
2121
def __init__(
2222
self,
2323
label: str | None = None,
24-
additional_props: dict | None = None,
2524
*,
2625
key: str | None = None,
27-
timestamp: int | float | None = None,
26+
type: Literal['divider'] | None = None,
2827
group: str | None = None,
2928
icon: str | None = None,
3029
disabled: bool | None = None,
30+
dashed: bool | None = None,
31+
additional_props: dict | None = None,
3132
as_item: str | None = None,
3233
_internal: None = None,
3334
# gradio properties
@@ -46,7 +47,8 @@ def __init__(
4647
**kwargs)
4748
self.additional_props = additional_props
4849
self.label = label
49-
self.timestamp = timestamp
50+
self.type = type
51+
self.dashed = dashed
5052
self.group = group
5153
self.icon = icon
5254
self.disabled = disabled

backend/modelscope_studio/components/antdx/prompts/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ class AntdXPrompts(ModelScopeLayoutComponent):
2727

2828
def __init__(
2929
self,
30-
additional_props: dict | None = None,
3130
*,
3231
items: list[dict] | None = None,
3332
prefix_cls: str | None = None,
3433
title: str | None = None,
3534
vertical: bool | None = None,
35+
fade_in: bool | None = None,
36+
fade_in_left: bool | None = None,
3637
wrap: bool | None = None,
37-
styles: dict | str | None= None,
38-
class_names: dict | str | None= None,
38+
styles: dict | str | None = None,
39+
class_names: dict | str | None = None,
3940
root_class_name: str | None = None,
41+
additional_props: dict | None = None,
4042
as_item: str | None = None,
4143
_internal: None = None,
4244
# gradio properties
@@ -58,6 +60,8 @@ def __init__(
5860
self.prefix_cls = prefix_cls
5961
self.title = title
6062
self.vertical = vertical
63+
self.fade_in = fade_in
64+
self.fade_in_left = fade_in_left
6165
self.wrap = wrap
6266
self.styles = styles
6367
self.class_names = class_names

backend/modelscope_studio/components/antdx/prompts/item/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class AntdXPromptsItem(ModelScopeLayoutComponent):
1818
def __init__(
1919
self,
2020
label: str | None = None,
21-
additional_props: dict | None = None,
2221
*,
2322
key: str | None = None,
2423
description: str | None = None,
2524
icon: str | None = None,
2625
disabled: bool | None = None,
26+
additional_props: dict | None = None,
2727
as_item: str | None = None,
2828
_internal: None = None,
2929
# gradio properties

backend/modelscope_studio/components/antdx/sender/__init__.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from ....utils.dev import ModelScopeDataLayoutComponent, resolve_frontend_dir
99
from .header import AntdXSenderHeader
10+
from .switch import AntdXSenderSwitch
1011

1112

1213
# as inputs, outputs
@@ -15,6 +16,7 @@ class AntdXSender(ModelScopeDataLayoutComponent):
1516
Ant Design X: https://x.ant.design/components/sender
1617
"""
1718
Header = AntdXSenderHeader
19+
Switch = AntdXSenderSwitch
1820

1921
EVENTS = [
2022
EventListener("change",
@@ -51,32 +53,41 @@ class AntdXSender(ModelScopeDataLayoutComponent):
5153
EventListener("paste_file",
5254
callback=lambda block: block._internal.update(
5355
bind_pasteFile_event=True)),
56+
EventListener("skill_closable_close",
57+
callback=lambda block: block._internal.update(
58+
bind_skill_closable_close_event=True)),
5459
]
5560

5661
# supported slots
57-
SLOTS = ['actions', 'header', 'prefix', 'footer']
62+
SLOTS = [
63+
'suffix', 'header', 'prefix', 'footer', 'skill.title',
64+
'skill.toolTip.title'
65+
'skill.closable.closeIcon'
66+
]
5867

5968
def __init__(
6069
self,
6170
value: str | None = None,
62-
additional_props: dict | None = None,
6371
*,
64-
auto_size: bool | dict | None = None,
65-
footer: str | None = None,
66-
actions: str | bool | None = None,
6772
allow_speech: bool | dict | None = None,
68-
class_names: dict | str | None= None,
73+
class_names: dict | str | None = None,
6974
components: dict | None = None,
7075
default_value: str | None = None,
71-
loading: bool | None = None,
7276
disabled: bool | None = None,
77+
auto_size: bool | dict | None = None,
78+
loading: bool | None = None,
79+
suffix: str | bool | None = None,
80+
footer: str | None = None,
7381
header: str | None = None,
7482
prefix: str | None = None,
7583
read_only: bool | None = None,
76-
styles: dict | str | None= None,
84+
styles: dict | str | None = None,
7785
submit_type: Literal['enter', 'shiftEnter'] | None = None,
7886
placeholder: str | None = None,
87+
slot_config: list[dict] | None = None,
88+
skill: dict | None = None,
7989
root_class_name: str | None = None,
90+
additional_props: dict | None = None,
8091
as_item: str | None = None,
8192
_internal: None = None,
8293
# gradio properties
@@ -108,7 +119,9 @@ def __init__(
108119
self.read_only = read_only
109120
self.loading = loading
110121
self.header = header
111-
self.actions = actions
122+
self.suffix = suffix
123+
self.slot_config = slot_config
124+
self.skill = skill
112125
self.placeholder = placeholder
113126
self.root_class_name = root_class_name
114127

backend/modelscope_studio/components/antdx/sender/header/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class AntdXSenderHeader(ModelScopeLayoutComponent):
2121

2222
def __init__(
2323
self,
24-
additional_props: dict | None = None,
2524
*,
2625
closable: bool | None = None,
2726
force_render: bool | None = None,
28-
styles: dict | str | None= None,
29-
class_names: dict | str | None= None,
27+
styles: dict | str | None = None,
28+
class_names: dict | str | None = None,
3029
open: bool | None = None,
3130
title: str | None = None,
31+
additional_props: dict | None = None,
3232
as_item: str | None = None,
3333
_internal: None = None,
3434
# gradio properties
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
from __future__ import annotations
2+
3+
from gradio.events import EventListener
4+
5+
from .....utils.dev import ModelScopeDataLayoutComponent, resolve_frontend_dir
6+
7+
8+
class AntdXSenderSwitch(ModelScopeDataLayoutComponent):
9+
"""
10+
Ant Design X: https://x.ant.design/components/sender
11+
"""
12+
EVENTS = [
13+
EventListener("change",
14+
callback=lambda block: block._internal.update(
15+
bind_change_event=True)),
16+
]
17+
18+
# supported slots
19+
SLOTS = ['checkedChildren', 'unCheckedChildren', 'icon']
20+
21+
def __init__(
22+
self,
23+
value: bool | None = None,
24+
*,
25+
checked_children: str | None = None,
26+
un_checked_children: str | None = None,
27+
icon: str | None = None,
28+
disabled: bool | None = None,
29+
loading: bool | None = None,
30+
default_value: bool | None = None,
31+
styles: dict | str | None = None,
32+
class_names: dict | str | None = None,
33+
root_class_name: str | None = None,
34+
additional_props: dict | None = None,
35+
as_item: str | None = None,
36+
_internal: None = None,
37+
# gradio properties
38+
visible: bool = True,
39+
elem_id: str | None = None,
40+
elem_classes: list[str] | str | None = None,
41+
elem_style: dict | None = None,
42+
render: bool = True,
43+
**kwargs):
44+
super().__init__(value=value,
45+
visible=visible,
46+
elem_id=elem_id,
47+
elem_classes=elem_classes,
48+
render=render,
49+
as_item=as_item,
50+
elem_style=elem_style,
51+
**kwargs)
52+
self.additional_props = additional_props
53+
self.styles = styles
54+
self.class_names = class_names
55+
self.root_class_name = root_class_name
56+
self.checked_children = checked_children
57+
self.un_checked_children = un_checked_children
58+
self.icon = icon
59+
self.disabled = disabled
60+
self.loading = loading
61+
self.default_value = default_value
62+
63+
FRONTEND_DIR = resolve_frontend_dir("sender", 'switch', type="antdx")
64+
65+
@property
66+
def skip_api(self):
67+
return True
68+
69+
def preprocess(self, payload: None) -> None:
70+
return payload
71+
72+
def postprocess(self, value: None) -> None:
73+
74+
return value
75+
76+
def example_payload(self) -> None:
77+
return None
78+
79+
def example_value(self) -> None:
80+
return None

backend/modelscope_studio/components/antdx/thought_chain/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
88
from .item import AntdXThoughtChainItem
9+
from .thought_chain_item import AntdXThoughtChainThoughtChainItem
910

1011

1112
class AntdXThoughtChain(ModelScopeLayoutComponent):
@@ -14,11 +15,12 @@ class AntdXThoughtChain(ModelScopeLayoutComponent):
1415
"""
1516

1617
Item = AntdXThoughtChainItem
18+
ThoughtChainItem = AntdXThoughtChainThoughtChainItem
1719

1820
EVENTS = [
19-
EventListener("collapsible_expand",
21+
EventListener("expand",
2022
callback=lambda block: block._internal.update(
21-
bind_collapsible_expand_event=True),
23+
bind_expand_event=True),
2224
doc="Callback function when expanded keys change."),
2325
]
2426

@@ -27,14 +29,15 @@ class AntdXThoughtChain(ModelScopeLayoutComponent):
2729

2830
def __init__(
2931
self,
30-
additional_props: dict | None = None,
3132
*,
32-
collapsible: bool | dict | None = None,
33+
expanded_keys: list[str] | None = None,
34+
default_expanded_keys: list[str] | None = None,
3335
items: list[dict] | None = None,
34-
size: Literal['small', 'middle', 'large'] | None = None,
36+
line: bool | Literal['solid', 'dashed', "dotted"] | None = None,
3537
prefix_cls: str | None = None,
36-
styles: dict | str | None= None,
37-
class_names: dict | str | None= None,
38+
additional_props: dict | None = None,
39+
styles: dict | str | None = None,
40+
class_names: dict | str | None = None,
3841
root_class_name: str | None = None,
3942
as_item: str | None = None,
4043
_internal: None = None,
@@ -53,9 +56,10 @@ def __init__(
5356
elem_style=elem_style,
5457
**kwargs)
5558
self.additional_props = additional_props
56-
self.collapsible = collapsible
5759
self.items = items
58-
self.size = size
60+
self.expanded_keys = expanded_keys
61+
self.default_expanded_keys = default_expanded_keys
62+
self.line = line
5963
self.prefix_cls = prefix_cls
6064
self.styles = styles
6165
self.class_names = class_names

0 commit comments

Comments
 (0)