Coloring commited on
Commit
ed7ca64
·
1 Parent(s): 6f37be4

Mirgate to ModelScope Studio 2.0

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README-zh_CN.md +9 -17
  2. README.md +9 -17
  3. api/app.py +0 -19
  4. api/load-zh_CN.md +0 -30
  5. api/load.md +0 -30
  6. app.py +26 -8
  7. components/antd/config_provider/demos/basic.py +2 -2
  8. components/antd/masonry/README-zh_CN.md +9 -0
  9. components/antd/masonry/README.md +9 -0
  10. components/{legacy/MultimodalInput → antd/masonry}/app.py +1 -1
  11. components/antd/masonry/demos/basic.py +36 -0
  12. components/antd/masonry/demos/columns.py +49 -0
  13. components/antd/masonry/demos/responsive.py +40 -0
  14. components/antdx/actions/demos/basic.py +20 -20
  15. components/antdx/attachments/README-zh_CN.md +0 -1
  16. components/antdx/attachments/README.md +0 -1
  17. components/antdx/attachments/demos/file_card.py +0 -71
  18. components/antdx/bubble/demos/basic.py +22 -14
  19. components/antdx/bubble/demos/bubble_list.py +14 -16
  20. components/antdx/bubble/demos/chatbot.py +6 -12
  21. components/antdx/bubble/demos/custom_list_content.py +18 -24
  22. components/antdx/bubble/demos/typing_effect.py +9 -6
  23. components/antdx/bubble/demos/variant.py +17 -8
  24. components/antdx/code_highlighter/README-zh_CN.md +7 -0
  25. components/antdx/code_highlighter/README.md +7 -0
  26. components/{legacy/Chatbot → antdx/code_highlighter}/app.py +1 -1
  27. components/antdx/code_highlighter/demos/basic.py +75 -0
  28. components/antdx/file_card/README-zh_CN.md +7 -0
  29. components/antdx/file_card/README.md +7 -0
  30. components/{legacy/Flow → antdx/file_card}/app.py +1 -1
  31. components/antdx/file_card/demos/basic.py +96 -0
  32. components/antdx/folder/README-zh_CN.md +7 -0
  33. components/antdx/folder/README.md +7 -0
  34. components/{legacy/Lifecycle → antdx/folder}/app.py +1 -1
  35. components/antdx/folder/demos/basic.py +110 -0
  36. components/antdx/mermaid/README-zh_CN.md +7 -0
  37. components/antdx/mermaid/README.md +7 -0
  38. components/antdx/mermaid/app.py +6 -0
  39. components/{legacy/Markdown/demos/custom_tags/accordion → antdx/mermaid/demos}/basic.py +8 -11
  40. components/antdx/notification/README-zh_CN.md +7 -0
  41. components/antdx/notification/README.md +7 -0
  42. components/antdx/notification/app.py +6 -0
  43. components/antdx/notification/demos/basic.py +23 -0
  44. components/antdx/prompts/demos/nest_usage.py +1 -1
  45. components/antdx/sources/README-zh_CN.md +7 -0
  46. components/antdx/sources/README.md +7 -0
  47. components/antdx/sources/app.py +6 -0
  48. components/antdx/sources/demos/basic.py +64 -0
  49. components/antdx/think/README-zh_CN.md +7 -0
  50. components/antdx/think/README.md +7 -0
README-zh_CN.md CHANGED
@@ -27,7 +27,9 @@
27
 
28
  ## 依赖
29
 
30
- - Gradio >= 4.43.0
 
 
31
 
32
  ## 安装
33
 
@@ -35,22 +37,12 @@
35
  pip install modelscope_studio
36
  ```
37
 
38
- ## 示例
39
-
40
- <demo name="example"></demo>
41
-
42
- ## 迁移到 1.0
43
-
44
- 如果您在之前使用了`modelscope_studio`的组件,并且想要在新版本中继续使用。不需要对原有组件做任何修改,只需要在外层引入`ms.Application`即可。
45
 
46
- ```python
47
- import gradio as gr
48
- import modelscope_studio.components.base as ms
49
- import modelscope_studio.components.legacy as mgr
50
 
51
- with gr.Blocks() as demo:
52
- with ms.Application():
53
- mgr.Chatbot()
54
 
55
- demo.launch()
56
- ```
 
27
 
28
  ## 依赖
29
 
30
+ - Gradio >= 6.0.0
31
+
32
+ > 注意:您的 Gradio 版本必须`<=6.8.0`,[为什么?](https://github.com/gradio-app/gradio/issues/13131)
33
 
34
  ## 安装
35
 
 
37
  pip install modelscope_studio
38
  ```
39
 
40
+ 如果您需要使用`4.43.0 <= Gradio < 6.0.0`,请使用 1.x 版本:
 
 
 
 
 
 
41
 
42
+ ```sh
43
+ pip install modelscope_studio~=1.0
44
+ ```
 
45
 
46
+ ## 示例
 
 
47
 
48
+ <demo name="example"></demo>
 
README.md CHANGED
@@ -45,7 +45,9 @@ However, when your application needs Gradio to handle more built-in data on the
45
 
46
  ## Dependencies
47
 
48
- - Gradio >= 4.43.0
 
 
49
 
50
  ## Installation
51
 
@@ -53,22 +55,12 @@ However, when your application needs Gradio to handle more built-in data on the
53
  pip install modelscope_studio
54
  ```
55
 
56
- ## Examples
57
-
58
- <demo name="example"></demo>
59
-
60
- ## Migration to 1.0
61
-
62
- If you have used the `modelscope_studio` component before and want to continue using it in the new version, you do not need to make any changes to the original component, just import `ms.Application` in the outer layer.
63
 
64
- ```python
65
- import gradio as gr
66
- import modelscope_studio.components.base as ms
67
- import modelscope_studio.components.legacy as mgr
68
 
69
- with gr.Blocks() as demo:
70
- with ms.Application():
71
- mgr.Chatbot()
72
 
73
- demo.launch()
74
- ```
 
45
 
46
  ## Dependencies
47
 
48
+ - Gradio >= 6.0.0
49
+
50
+ > Note: Your Gradio version must`<=6.8.0`, [why?](https://github.com/gradio-app/gradio/issues/13131)
51
 
52
  ## Installation
53
 
 
55
  pip install modelscope_studio
56
  ```
57
 
58
+ If you need to use `4.43.0 <= Gradio < 6.0.0`, please use 1.x version:
 
 
 
 
 
 
59
 
60
+ ```sh
61
+ pip install modelscope_studio~=1.0
62
+ ```
 
63
 
64
+ ## Examples
 
 
65
 
66
+ <demo name="example"></demo>
 
api/app.py DELETED
@@ -1,19 +0,0 @@
1
- import os
2
-
3
- from components.legacy.Docs import Docs
4
-
5
-
6
- def resolve(relative_path: str):
7
- return os.path.join(os.path.dirname(__file__), relative_path)
8
-
9
-
10
- docs = Docs(
11
- __file__,
12
- markdown_files=([
13
- filename for filename in os.listdir(resolve('.'))
14
- if filename.endswith(".md")
15
- ]),
16
- )
17
-
18
- if __name__ == "__main__":
19
- docs.render().queue().launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api/load-zh_CN.md DELETED
@@ -1,30 +0,0 @@
1
- # load
2
-
3
- 该特性与 [gr.load](https://www.gradio.app/docs/gradio/load) 类似。允许用户从已有创空间 [ModelScope Studio](https://modelscope.cn/studios) 仓库构造 demo。
4
-
5
- ## 如何使用
6
-
7
- ### 基本使用
8
-
9
- ```python
10
- import modelscope_studio.components.legacy as mgr
11
- demo = mgr.load("modelscope/modelscope-studio")
12
- demo.launch()
13
- ```
14
-
15
- ### 使用访问令牌
16
-
17
- 使用访问令牌来加载私有创空间。在这里找到您的 sdk 令牌:https://modelscope.cn/my/myaccesstoken。
18
-
19
- ```python
20
- import modelscope_studio.components.legacy as mgr
21
- demo = mgr.load("modelscope/modelscope-studio", token="YOUR_ACCESS_TOKEN")
22
- demo.launch()
23
- ```
24
-
25
- ## 初始化
26
-
27
- | 属性 | 类型 | 默认值 | 描述 |
28
- | ----- | ---- | ------ | ---------------------------------------------------------------------------------------------------- |
29
- | name | str | None | 必填。 创空间名称(如: "modelscope/modelscope-studio")。 |
30
- | token | str | None | 用于加载私有创空间的可选访问令牌。 在这里找到您的 sdk 令牌:https://modelscope.cn/my/myaccesstoken。 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api/load.md DELETED
@@ -1,30 +0,0 @@
1
- # load
2
-
3
- This feature is similar to [gr.load](https://www.gradio.app/docs/gradio/load). Allow users to Construct a demo from a [ModelScope Studio](https://modelscope.cn/studios) repo.
4
-
5
- ## How to Use
6
-
7
- ### Basic Usage
8
-
9
- ```python
10
- import modelscope_studio.components.legacy as mgr
11
- demo = mgr.load("modelscope/modelscope-studio")
12
- demo.launch()
13
- ```
14
-
15
- ### With Access Token
16
-
17
- Use the access token to load a private ModelScope Studio repo. Find your sdk token here: https://modelscope.cn/my/myaccesstoken.
18
-
19
- ```python
20
- import modelscope_studio.components.legacy as mgr
21
- demo = mgr.load("modelscope/modelscope-studio", token="YOUR_ACCESS_TOKEN")
22
- demo.launch()
23
- ```
24
-
25
- ## Initialization
26
-
27
- | Parameter | Type | Default Value | Description |
28
- | --------- | ---- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
29
- | name | str | None | required. the name of the ModelScope Studio repo (e.g. "modelscope/modelscope-studio"). |
30
- | token | str | None | optional access token for loading private ModelScope Studio repo. Find your sdk token here: https://modelscope.cn/my/myaccesstoken. |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -6,7 +6,6 @@ import modelscope_studio.components.base as ms
6
  from helper.Docs import Docs
7
  from helper.env import is_modelscope_studio
8
  from helper.Site import Site
9
- from legacy_app import legacy_demo
10
 
11
  is_dev = os.environ.get("GRADIO_WATCH_MODULE_NAME") == 'docs.app'
12
 
@@ -225,6 +224,9 @@ antd_menu_items = [{
225
  }, {
226
  "label": get_text("Layout", "Layout 布局"),
227
  "key": "layout"
 
 
 
228
  }, {
229
  "label": get_text("Space", "Space 间距"),
230
  "key": "space"
@@ -452,6 +454,9 @@ antdx_menu_items = [{
452
  }, {
453
  "label": get_text("Conversations", "Conversations 管理对话"),
454
  "key": "conversations"
 
 
 
455
  }]
456
  }, {
457
  "label":
@@ -486,6 +491,9 @@ antdx_menu_items = [{
486
  "type":
487
  "group",
488
  "children": [{
 
 
 
489
  "label": get_text("ThoughtChain", "ThoughtChain 思考链"),
490
  "key": "thought_chain"
491
  }]
@@ -497,6 +505,21 @@ antdx_menu_items = [{
497
  "children": [{
498
  "label": get_text("Actions", "Actions 操作列表"),
499
  "key": "actions"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  }]
501
  }, {
502
  "label":
@@ -573,11 +596,6 @@ tabs = [
573
  "default_active_key": "overview",
574
  "menus": antdx_menu_items,
575
  },
576
- {
577
- "label": get_text("Version 0.x", "0.x 版本"),
578
- "key": "legacy",
579
- "content": legacy_demo
580
- } if not is_dev else None,
581
  ]
582
 
583
  site = Site(
@@ -593,8 +611,8 @@ site = Site(
593
  default_active_tab=default_active_tab,
594
  logo=logo)
595
 
596
- demo = site.render()
597
 
598
  if __name__ == "__main__":
599
  demo.queue(default_concurrency_limit=100,
600
- max_size=100).launch(ssr_mode=False, max_threads=100)
 
6
  from helper.Docs import Docs
7
  from helper.env import is_modelscope_studio
8
  from helper.Site import Site
 
9
 
10
  is_dev = os.environ.get("GRADIO_WATCH_MODULE_NAME") == 'docs.app'
11
 
 
224
  }, {
225
  "label": get_text("Layout", "Layout 布局"),
226
  "key": "layout"
227
+ }, {
228
+ "label": get_text("Masonry", "Masonry 瀑布流"),
229
+ "key": "masonry"
230
  }, {
231
  "label": get_text("Space", "Space 间距"),
232
  "key": "space"
 
454
  }, {
455
  "label": get_text("Conversations", "Conversations 管理对话"),
456
  "key": "conversations"
457
+ }, {
458
+ "label": get_text("Notification", "Notification 系统通知"),
459
+ "key": "notification"
460
  }]
461
  }, {
462
  "label":
 
491
  "type":
492
  "group",
493
  "children": [{
494
+ "label": get_text("Think", "Think 思考过程"),
495
+ "key": "think"
496
+ }, {
497
  "label": get_text("ThoughtChain", "ThoughtChain 思考链"),
498
  "key": "thought_chain"
499
  }]
 
505
  "children": [{
506
  "label": get_text("Actions", "Actions 操作列表"),
507
  "key": "actions"
508
+ }, {
509
+ "label": get_text("CodeHighlighter", "CodeHighlighter 代码高亮"),
510
+ "key": "code_highlighter"
511
+ }, {
512
+ "label": get_text("FileCard", "FileCard 文件卡片"),
513
+ "key": "file_card"
514
+ }, {
515
+ "label": get_text("Folder", "Folder 文件夹"),
516
+ "key": "folder"
517
+ }, {
518
+ "label": get_text("Mermaid", "Mermaid 图表工具"),
519
+ "key": "mermaid"
520
+ }, {
521
+ "label": get_text("Sources", "Sources 来源引用"),
522
+ "key": "sources"
523
  }]
524
  }, {
525
  "label":
 
596
  "default_active_key": "overview",
597
  "menus": antdx_menu_items,
598
  },
 
 
 
 
 
599
  ]
600
 
601
  site = Site(
 
611
  default_active_tab=default_active_tab,
612
  logo=logo)
613
 
614
+ demo, css = site.render()
615
 
616
  if __name__ == "__main__":
617
  demo.queue(default_concurrency_limit=100,
618
+ max_size=100).launch(css=css, ssr_mode=False, max_threads=100)
components/antd/config_provider/demos/basic.py CHANGED
@@ -10,7 +10,7 @@ with gr.Blocks() as demo:
10
  with antd.ConfigProvider(
11
  locale=default_locale,
12
  direction=default_direction,
13
- theme=dict(token=dict(
14
  colorPrimary=default_color))) as config_provider:
15
  with antd.Card():
16
  with ms.Div(elem_style=dict(marginBottom=16)):
@@ -61,7 +61,7 @@ with gr.Blocks() as demo:
61
  outputs=[config_provider])
62
  gr.on(
63
  [theme.change, color.change],
64
- fn=lambda _theme, _color: gr.update(theme=dict(
65
  token=dict(colorPrimary=_color) if _color else None,
66
  algorithm=dict(dark=True
67
  if _theme and 'dark' in _theme else False,
 
10
  with antd.ConfigProvider(
11
  locale=default_locale,
12
  direction=default_direction,
13
+ theme_config=dict(token=dict(
14
  colorPrimary=default_color))) as config_provider:
15
  with antd.Card():
16
  with ms.Div(elem_style=dict(marginBottom=16)):
 
61
  outputs=[config_provider])
62
  gr.on(
63
  [theme.change, color.change],
64
+ fn=lambda _theme, _color: gr.update(theme_config=dict(
65
  token=dict(colorPrimary=_color) if _color else None,
66
  algorithm=dict(dark=True
67
  if _theme and 'dark' in _theme else False,
components/antd/masonry/README-zh_CN.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Masonry
2
+
3
+ A masonry/waterfall layout component for displaying content with different heights. See [Ant Design](https://ant.design/components/masonry/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
8
+ <demo name="columns" title="Custom Columns"></demo>
9
+ <demo name="responsive" title="Responsive Layout"></demo>
components/antd/masonry/README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Masonry
2
+
3
+ A masonry/waterfall layout component for displaying content with different heights. See [Ant Design](https://ant.design/components/masonry/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
8
+ <demo name="columns" title="Custom Columns"></demo>
9
+ <demo name="responsive" title="Responsive Layout"></demo>
components/{legacy/MultimodalInput → antd/masonry}/app.py RENAMED
@@ -1,4 +1,4 @@
1
- from components.legacy.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
 
1
+ from helper.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
components/antd/masonry/demos/basic.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.base as ms
4
+
5
+ card_contents = [
6
+ ("Nature", "The natural world is full of wonder and beauty.", 120),
7
+ ("Technology", "Modern technology shapes how we live and work every day.",
8
+ 100),
9
+ ("Travel",
10
+ "Exploring new destinations broadens the mind and enriches the soul.",
11
+ 140),
12
+ ("Food", "Culinary traditions reflect the culture and history of a place.",
13
+ 80),
14
+ ("Science",
15
+ "Scientific discoveries have transformed our understanding of the universe.",
16
+ 160),
17
+ ("Art",
18
+ "Artistic expression takes countless forms across different cultures and eras.",
19
+ 110),
20
+ ]
21
+
22
+ with gr.Blocks() as demo:
23
+ with ms.Application():
24
+ with antd.ConfigProvider():
25
+ with antd.Masonry(columns=3, gutter=16):
26
+ for title, content, height in card_contents:
27
+ with antd.Masonry.Item():
28
+ with antd.Card(title=title,
29
+ elem_style=dict(marginBottom=0)):
30
+ ms.Div(content,
31
+ elem_style=dict(height=height,
32
+ display='flex',
33
+ alignItems='center'))
34
+
35
+ if __name__ == "__main__":
36
+ demo.queue().launch()
components/antd/masonry/demos/columns.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.base as ms
4
+
5
+ card_contents = [
6
+ ("Card 1", 120),
7
+ ("Card 2", 80),
8
+ ("Card 3", 160),
9
+ ("Card 4", 100),
10
+ ("Card 5", 140),
11
+ ("Card 6", 90),
12
+ ("Card 7", 110),
13
+ ("Card 8", 130),
14
+ ]
15
+
16
+ default_columns = 3
17
+
18
+ with gr.Blocks() as demo:
19
+ with ms.Application():
20
+ with antd.ConfigProvider():
21
+ with antd.Flex(gap="middle", vertical=True):
22
+ ms.Div("Select number of columns:")
23
+ columns_segmented = antd.Segmented(default_columns,
24
+ options=[
25
+ dict(label="1 Column",
26
+ value=1),
27
+ dict(label="2 Columns",
28
+ value=2),
29
+ dict(label="3 Columns",
30
+ value=3),
31
+ dict(label="4 Columns",
32
+ value=4),
33
+ ])
34
+ with antd.Masonry(columns=default_columns,
35
+ gutter=16) as masonry:
36
+ for title, height in card_contents:
37
+ with antd.Masonry.Item():
38
+ with antd.Card(title=title,
39
+ elem_style=dict(marginBottom=0)):
40
+ ms.Div(elem_style=dict(height=height,
41
+ background='#f0f5ff',
42
+ borderRadius=4))
43
+ columns_segmented.change(
44
+ fn=lambda _columns: gr.update(columns=_columns),
45
+ inputs=[columns_segmented],
46
+ outputs=[masonry])
47
+
48
+ if __name__ == "__main__":
49
+ demo.queue().launch()
components/antd/masonry/demos/responsive.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.base as ms
4
+
5
+ items = [
6
+ dict(color='#1677ff', height=150, label='Item A'),
7
+ dict(color='#52c41a', height=80, label='Item B'),
8
+ dict(color='#fa8c16', height=200, label='Item C'),
9
+ dict(color='#722ed1', height=120, label='Item D'),
10
+ dict(color='#eb2f96', height=100, label='Item E'),
11
+ dict(color='#13c2c2', height=180, label='Item F'),
12
+ dict(color='#faad14', height=90, label='Item G'),
13
+ dict(color='#f5222d', height=160, label='Item H'),
14
+ dict(color='#1677ff', height=110, label='Item I'),
15
+ dict(color='#52c41a', height=140, label='Item J'),
16
+ dict(color='#fa8c16', height=70, label='Item K'),
17
+ dict(color='#722ed1', height=190, label='Item L'),
18
+ ]
19
+
20
+ with gr.Blocks() as demo:
21
+ with ms.Application():
22
+ with antd.ConfigProvider():
23
+ with antd.Masonry(columns=4, gutter=12):
24
+ for item in items:
25
+ with antd.Masonry.Item():
26
+ ms.Div(item['label'],
27
+ elem_style=dict(
28
+ height=item['height'],
29
+ background=item['color'],
30
+ borderRadius=8,
31
+ display='flex',
32
+ alignItems='center',
33
+ justifyContent='center',
34
+ color='#fff',
35
+ fontSize=16,
36
+ fontWeight='bold',
37
+ ))
38
+
39
+ if __name__ == "__main__":
40
+ demo.queue().launch()
components/antdx/actions/demos/basic.py CHANGED
@@ -18,33 +18,33 @@ with gr.Blocks() as demo:
18
  with ms.Application():
19
  with antdx.XProvider():
20
  with antdx.Actions() as actions:
21
- with antdx.Actions.Item(key="retry", label="Retry"):
22
  with ms.Slot("icon"):
23
  antd.Icon("RedoOutlined")
24
- with antdx.Actions.Item(key="copy", label="Copy"):
25
- with ms.Slot("icon"):
26
- antd.Icon("CopyOutlined")
27
- antd.Divider("More Menu Items")
28
  with antdx.Actions() as actions2:
29
- with antdx.Actions.Item(key="retry", label="Retry"):
30
  with ms.Slot("icon"):
31
  antd.Icon("RedoOutlined")
32
- with antdx.Actions.Item(key="copy", label="Copy"):
33
  with ms.Slot("icon"):
34
  antd.Icon("CopyOutlined")
35
- with antdx.Actions.Item(key="more"):
36
- with antdx.Actions.Item(key="share", label="Share"):
37
- with ms.Slot("icon"):
38
- antd.Icon("ShareAltOutlined")
39
- antdx.Actions.Item(key="qq", label="QQ")
40
- antdx.Actions.Item(key="wechat", label="WeChat")
41
- antdx.Actions.Item(key="import", label="Import")
42
- with antdx.Actions.Item(
43
- key="delete", label="Delete",
44
- danger=True) as actions_delete_item:
45
- with ms.Slot("icon"):
46
- antd.Icon("DeleteOutlined")
47
- with antdx.Actions.Item(key="clear", label="Clear"):
48
  with ms.Slot("icon"):
49
  antd.Icon("ClearOutlined")
50
 
 
18
  with ms.Application():
19
  with antdx.XProvider():
20
  with antdx.Actions() as actions:
21
+ with antdx.Actions.ActionItem(key="retry", label="Retry"):
22
  with ms.Slot("icon"):
23
  antd.Icon("RedoOutlined")
24
+ with antdx.Actions.ActionItem(key="copy", label="Copy"):
25
+ with ms.Slot("actionRender"):
26
+ antdx.Actions.Copy(text="Copy Text")
27
+ antd.Divider("More Menu ActionItems")
28
  with antdx.Actions() as actions2:
29
+ with antdx.Actions.ActionItem(key="retry", label="Retry"):
30
  with ms.Slot("icon"):
31
  antd.Icon("RedoOutlined")
32
+ with antdx.Actions.ActionItem(key="copy", label="Copy"):
33
  with ms.Slot("icon"):
34
  antd.Icon("CopyOutlined")
35
+ with antdx.Actions.ActionItem(key="more"):
36
+ with ms.Slot("subItems"):
37
+ with antdx.Actions.ActionItem(key="share",
38
+ label="Share"):
39
+ with ms.Slot("icon"):
40
+ antd.Icon("ShareAltOutlined")
41
+ antdx.Actions.ActionItem(key="import", label="Import")
42
+ with antdx.Actions.ActionItem(
43
+ key="delete", label="Delete",
44
+ danger=True) as actions_delete_item:
45
+ with ms.Slot("icon"):
46
+ antd.Icon("DeleteOutlined")
47
+ with antdx.Actions.ActionItem(key="clear", label="Clear"):
48
  with ms.Slot("icon"):
49
  antd.Icon("ClearOutlined")
50
 
components/antdx/attachments/README-zh_CN.md CHANGED
@@ -6,4 +6,3 @@ Display the collection of attachment information. See [Ant Design X](https://x.a
6
 
7
  <demo name="basic"></demo>
8
  <demo name="combination" title="Combination"></demo>
9
- <demo name="file_card" title="File Card"></demo>
 
6
 
7
  <demo name="basic"></demo>
8
  <demo name="combination" title="Combination"></demo>
 
components/antdx/attachments/README.md CHANGED
@@ -6,4 +6,3 @@ Display the collection of attachment information. See [Ant Design X](https://x.a
6
 
7
  <demo name="basic"></demo>
8
  <demo name="combination" title="Combination"></demo>
9
- <demo name="file_card" title="File Card"></demo>
 
6
 
7
  <demo name="basic"></demo>
8
  <demo name="combination" title="Combination"></demo>
 
components/antdx/attachments/demos/file_card.py DELETED
@@ -1,71 +0,0 @@
1
- import gradio as gr
2
- import modelscope_studio.components.antd as antd
3
- import modelscope_studio.components.antdx as antdx
4
- import modelscope_studio.components.base as ms
5
-
6
- file_list = [
7
- {
8
- "uid": '1',
9
- "name": 'excel-file.xlsx',
10
- "size": 111111,
11
- },
12
- {
13
- "uid": '2',
14
- "name": 'word-file.docx',
15
- "size": 222222,
16
- },
17
- {
18
- "uid": '3',
19
- "name": 'image-file.png',
20
- "size": 333333,
21
- },
22
- {
23
- "uid": '4',
24
- "name": 'pdf-file.pdf',
25
- "size": 444444,
26
- },
27
- {
28
- "uid": '5',
29
- "name": 'ppt-file.pptx',
30
- "size": 555555,
31
- },
32
- {
33
- "uid": '6',
34
- "name": 'video-file.mp4',
35
- "size": 666666,
36
- },
37
- {
38
- "uid": '7',
39
- "name": 'audio-file.mp3',
40
- "size": 777777,
41
- },
42
- {
43
- "uid": '8',
44
- "name": 'zip-file.zip',
45
- "size": 888888,
46
- },
47
- {
48
- "uid": '9',
49
- "name": 'markdown-file.md',
50
- "size": 999999,
51
- "description": 'Custom description here',
52
- },
53
- {
54
- "uid": '10',
55
- "name": 'image-file.png',
56
- "thumbUrl":
57
- 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
58
- "url":
59
- 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
60
- "size": 123456,
61
- },
62
- ]
63
- with gr.Blocks() as demo:
64
- with ms.Application():
65
- with antdx.XProvider():
66
- with antd.Flex(vertical=True, gap="middle"):
67
- for file in file_list:
68
- antdx.Attachments.FileCard(item=file)
69
-
70
- if __name__ == "__main__":
71
- demo.queue().launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/antdx/bubble/demos/basic.py CHANGED
@@ -31,28 +31,32 @@ with gr.Blocks() as demo:
31
  with antd.Avatar(elem_style=fooAvatar):
32
  with ms.Slot("icon"):
33
  antd.Icon("UserOutlined")
34
- antdx.Bubble(placement="start",
35
- content="What a beautiful day!",
36
- avatar=dict(),
37
- styles={"avatar": hideAvatar})
 
38
  with antdx.Bubble(placement="end",
39
  content="Hi, good morning, I'm fine!"):
40
  with ms.Slot("avatar"):
41
  with antd.Avatar(elem_style=barAvatar):
42
  with ms.Slot("icon"):
43
  antd.Icon("UserOutlined")
44
- antdx.Bubble(placement="end",
45
- content="Thank you!",
46
- avatar=dict(),
47
- styles={"avatar": hideAvatar})
 
48
 
49
  antd.Divider("Header and footer")
50
 
51
  with antdx.Bubble(
52
  "Hello, welcome to use Ant Design X! Just ask if you have any questions.",
53
  header="Ant Design X"):
54
- with ms.Slot("avatar.icon"):
55
- antd.Icon("UserOutlined")
 
 
56
  with ms.Slot("footer"):
57
  with antd.Space(size="small"):
58
  with antd.Button(value=None,
@@ -73,16 +77,20 @@ with gr.Blocks() as demo:
73
  ms.Span("Loading State")
74
  loading_switch = antd.Switch(value=False)
75
  with antdx.Bubble("hello world !") as loading_bubble:
76
- with ms.Slot("avatar.icon"):
77
- antd.Icon("UserOutlined")
 
 
78
 
79
  loading_switch.change(fn=lambda x: gr.update(loading=x),
80
  inputs=[loading_switch],
81
  outputs=[loading_bubble])
82
  antd.Divider("Markdown")
83
  with antdx.Bubble():
84
- with ms.Slot("avatar.icon"):
85
- antd.Icon("UserOutlined")
 
 
86
  with ms.Slot("content"):
87
  ms.Markdown("Hello `Markdown`!")
88
 
 
31
  with antd.Avatar(elem_style=fooAvatar):
32
  with ms.Slot("icon"):
33
  antd.Icon("UserOutlined")
34
+ with antdx.Bubble(placement="start",
35
+ content="What a beautiful day!",
36
+ styles={"avatar": hideAvatar}):
37
+ with ms.Slot("avatar"):
38
+ antd.Avatar()
39
  with antdx.Bubble(placement="end",
40
  content="Hi, good morning, I'm fine!"):
41
  with ms.Slot("avatar"):
42
  with antd.Avatar(elem_style=barAvatar):
43
  with ms.Slot("icon"):
44
  antd.Icon("UserOutlined")
45
+ with antdx.Bubble(placement="end",
46
+ content="Thank you!",
47
+ styles={"avatar": hideAvatar}):
48
+ with ms.Slot("avatar"):
49
+ antd.Avatar()
50
 
51
  antd.Divider("Header and footer")
52
 
53
  with antdx.Bubble(
54
  "Hello, welcome to use Ant Design X! Just ask if you have any questions.",
55
  header="Ant Design X"):
56
+ with ms.Slot("avatar"):
57
+ with antd.Avatar():
58
+ with ms.Slot("icon"):
59
+ antd.Icon("UserOutlined")
60
  with ms.Slot("footer"):
61
  with antd.Space(size="small"):
62
  with antd.Button(value=None,
 
77
  ms.Span("Loading State")
78
  loading_switch = antd.Switch(value=False)
79
  with antdx.Bubble("hello world !") as loading_bubble:
80
+ with ms.Slot("avatar"):
81
+ with antd.Avatar():
82
+ with ms.Slot("icon"):
83
+ antd.Icon("UserOutlined")
84
 
85
  loading_switch.change(fn=lambda x: gr.update(loading=x),
86
  inputs=[loading_switch],
87
  outputs=[loading_bubble])
88
  antd.Divider("Markdown")
89
  with antdx.Bubble():
90
+ with ms.Slot("avatar"):
91
+ with antd.Avatar():
92
+ with ms.Slot("icon"):
93
+ antd.Icon("UserOutlined")
94
  with ms.Slot("content"):
95
  ms.Markdown("Hello `Markdown`!")
96
 
components/antdx/bubble/demos/bubble_list.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  import modelscope_studio.components.antd as antd
3
  import modelscope_studio.components.antdx as antdx
@@ -14,6 +16,7 @@ def get_bubble_items(count):
14
  "content": content,
15
  "key": i - 1
16
  })
 
17
  return result
18
 
19
 
@@ -27,20 +30,20 @@ with gr.Blocks() as demo:
27
 
28
  with ms.Application():
29
  state = gr.State({"history_count": 3})
30
- with antdx.XProvider():
31
  antd.Typography.Paragraph(
32
- "Preset Bubble list. Support auto scroll. Use roles to set default properties of Bubble."
33
  )
34
  with antd.Flex(gap="small", vertical=True):
35
  with antd.Flex(gap="small",
36
  elem_style=dict(alignSelf="flex-end")):
37
  add_bubble_btn = antd.Button("Add Bubble")
38
- scroll_btn = antd.Button("Scroll To First")
39
- with antdx.Bubble.List(items=get_bubble_items(3),
40
- elem_style=dict(maxHeight=300),
41
- elem_id="bubble-list") as bubble_list:
42
- # Define Roles
43
- with ms.Slot("roles"):
44
  with antdx.Bubble.List.Role(
45
  role="ai",
46
  placement="start",
@@ -51,9 +54,9 @@ with gr.Blocks() as demo:
51
  backgroundColor="#fde3cf")):
52
  with ms.Slot("icon"):
53
  antd.Icon("UserOutlined")
54
- # use messageRender to render markdown content
55
  with ms.Slot(
56
- "messageRender",
57
  params_mapping="""content => content"""):
58
  ms.Markdown()
59
 
@@ -67,17 +70,12 @@ with gr.Blocks() as demo:
67
  with ms.Slot("icon"):
68
  antd.Icon("UserOutlined")
69
  with ms.Slot(
70
- "messageRender",
71
  params_mapping="(content) => content"):
72
  ms.Markdown()
73
  add_bubble_btn.click(fn=add_bubble,
74
  inputs=[state],
75
  outputs=[state, bubble_list])
76
- scroll_btn.click(fn=None,
77
- js="""() => {
78
- const bubbleList = document.getElementById("bubble-list");
79
- bubbleList.scrollTo({ top:0, behavior:'smooth' });
80
- }""")
81
 
82
  if __name__ == "__main__":
83
  demo.queue().launch()
 
1
+ import time
2
+
3
  import gradio as gr
4
  import modelscope_studio.components.antd as antd
5
  import modelscope_studio.components.antdx as antdx
 
16
  "content": content,
17
  "key": i - 1
18
  })
19
+ time.sleep(2)
20
  return result
21
 
22
 
 
30
 
31
  with ms.Application():
32
  state = gr.State({"history_count": 3})
33
+ with antdx.XProvider(), ms.AutoLoading():
34
  antd.Typography.Paragraph(
35
+ "Preset Bubble list. Support auto scroll. Use role to set default properties of Bubble."
36
  )
37
  with antd.Flex(gap="small", vertical=True):
38
  with antd.Flex(gap="small",
39
  elem_style=dict(alignSelf="flex-end")):
40
  add_bubble_btn = antd.Button("Add Bubble")
41
+ with antdx.Bubble.List(
42
+ items=get_bubble_items(3),
43
+ elem_style={"height": 300},
44
+ class_names=dict(scroll="bubble-list")) as bubble_list:
45
+ # Define Role
46
+ with ms.Slot("role"):
47
  with antdx.Bubble.List.Role(
48
  role="ai",
49
  placement="start",
 
54
  backgroundColor="#fde3cf")):
55
  with ms.Slot("icon"):
56
  antd.Icon("UserOutlined")
57
+ # use contentRender to render markdown content
58
  with ms.Slot(
59
+ "contentRender",
60
  params_mapping="""content => content"""):
61
  ms.Markdown()
62
 
 
70
  with ms.Slot("icon"):
71
  antd.Icon("UserOutlined")
72
  with ms.Slot(
73
+ "contentRender",
74
  params_mapping="(content) => content"):
75
  ms.Markdown()
76
  add_bubble_btn.click(fn=add_bubble,
77
  inputs=[state],
78
  outputs=[state, bubble_list])
 
 
 
 
 
79
 
80
  if __name__ == "__main__":
81
  demo.queue().launch()
components/antdx/bubble/demos/chatbot.py CHANGED
@@ -64,12 +64,11 @@ with gr.Blocks() as demo:
64
  with antd.Flex(gap="small",
65
  elem_style=dict(alignSelf="flex-end")):
66
  add_bubble_btn = antd.Button("Add Bubble")
67
- scroll_btn = antd.Button("Scroll To First")
68
  with antdx.Bubble.List(items=default_history,
69
- elem_style=dict(maxHeight=500),
70
  elem_id="chatbot") as bubble_list:
71
- # Define Roles
72
- with ms.Slot("roles"):
73
  with antdx.Bubble.List.Role(
74
  role="ai",
75
  placement="start",
@@ -81,9 +80,9 @@ with gr.Blocks() as demo:
81
  backgroundColor="#fde3cf")):
82
  with ms.Slot("icon"):
83
  antd.Icon("UserOutlined")
84
- # use messageRender to render markdown content
85
  with ms.Slot(
86
- "messageRender",
87
  params_mapping="""content => content"""):
88
  ms.Markdown()
89
 
@@ -149,17 +148,12 @@ with gr.Blocks() as demo:
149
  with ms.Slot("icon"):
150
  antd.Icon("UserOutlined")
151
  with ms.Slot(
152
- "messageRender",
153
  params_mapping="(content) => content"):
154
  ms.Markdown()
155
  add_bubble_btn.click(fn=add_bubble,
156
  inputs=[state],
157
  outputs=[state, bubble_list])
158
- scroll_btn.click(fn=None,
159
- js="""() => {
160
- const bubbleList = document.getElementById("chatbot");
161
- bubbleList.scrollTo({ top:0, behavior:'smooth' });
162
- }""")
163
 
164
  if __name__ == "__main__":
165
  demo.queue().launch()
 
64
  with antd.Flex(gap="small",
65
  elem_style=dict(alignSelf="flex-end")):
66
  add_bubble_btn = antd.Button("Add Bubble")
 
67
  with antdx.Bubble.List(items=default_history,
68
+ elem_style=dict(height=500),
69
  elem_id="chatbot") as bubble_list:
70
+ # Define Role
71
+ with ms.Slot("role"):
72
  with antdx.Bubble.List.Role(
73
  role="ai",
74
  placement="start",
 
80
  backgroundColor="#fde3cf")):
81
  with ms.Slot("icon"):
82
  antd.Icon("UserOutlined")
83
+ # use contentRender to render markdown content
84
  with ms.Slot(
85
+ "contentRender",
86
  params_mapping="""content => content"""):
87
  ms.Markdown()
88
 
 
148
  with ms.Slot("icon"):
149
  antd.Icon("UserOutlined")
150
  with ms.Slot(
151
+ "contentRender",
152
  params_mapping="(content) => content"):
153
  ms.Markdown()
154
  add_bubble_btn.click(fn=add_bubble,
155
  inputs=[state],
156
  outputs=[state, bubble_list])
 
 
 
 
 
157
 
158
  if __name__ == "__main__":
159
  demo.queue().launch()
components/antdx/bubble/demos/custom_list_content.py CHANGED
@@ -45,16 +45,14 @@ items = [
45
  "content": [
46
  {
47
  "uid": '1',
48
- "name": 'excel-file.xlsx',
49
- "size": 111111,
50
  "description": 'Checking the data',
51
  },
52
  {
53
  "uid": '2',
54
- "name": 'word-file.docx',
55
- "size": 222222,
56
- "status": 'uploading',
57
- "percent": 23,
58
  },
59
  ],
60
  },
@@ -68,8 +66,8 @@ with gr.Blocks() as demo:
68
  "Customize the content of the bubble list, which is very useful for personalized customization scenarios."
69
  )
70
  with antdx.Bubble.List(items=items) as bubble_list:
71
- # Define Roles
72
- with ms.Slot("roles"):
73
  with antdx.Bubble.List.Role(role="ai-markdown",
74
  placement="start"):
75
  with ms.Slot("avatar"):
@@ -77,7 +75,7 @@ with gr.Blocks() as demo:
77
  backgroundColor="#fde3cf")):
78
  with ms.Slot("icon"):
79
  antd.Icon("UserOutlined")
80
- with ms.Slot("messageRender",
81
  params_mapping="(content) => content"):
82
  ms.Markdown()
83
  with antdx.Bubble.List.Role(role="ai-error-message",
@@ -87,32 +85,28 @@ with gr.Blocks() as demo:
87
  backgroundColor="#fde3cf")):
88
  with ms.Slot("icon"):
89
  antd.Icon("UserOutlined")
90
- with ms.Slot("messageRender",
91
  params_mapping="(content) => content"):
92
  antd.Typography.Text(type="danger")
93
- with antdx.Bubble.List.Role(
94
- role="ai-suggestion",
95
- placement="start",
96
- variant="borderless",
97
- avatar=dict(style=dict(visibility='hidden'))):
98
- with ms.Slot("messageRender",
99
  params_mapping="(items) => ({ items })"):
100
  prompts = antdx.Prompts(vertical=True)
101
 
102
- with antdx.Bubble.List.Role(
103
- role="ai-file",
104
- placement="start",
105
- variant="borderless",
106
- avatar=dict(style=dict(visibility='hidden'))):
107
- with ms.Slot("messageRender",
108
  params_mapping="""(content) => {
109
  return {
110
- each: content?.map(item => ({ item }))
111
  }
112
  }"""):
113
  with antd.Flex(vertical=True, gap="middle"):
114
  with ms.Each(as_item="each"):
115
- antdx.Attachments.FileCard()
116
 
117
  if __name__ == "__main__":
118
  demo.queue().launch()
 
45
  "content": [
46
  {
47
  "uid": '1',
48
+ "filename": 'excel-file.xlsx',
49
+ "byte": 111111,
50
  "description": 'Checking the data',
51
  },
52
  {
53
  "uid": '2',
54
+ "filename": 'word-file.docx',
55
+ "byte": 222222
 
 
56
  },
57
  ],
58
  },
 
66
  "Customize the content of the bubble list, which is very useful for personalized customization scenarios."
67
  )
68
  with antdx.Bubble.List(items=items) as bubble_list:
69
+ # Define Role
70
+ with ms.Slot("role"):
71
  with antdx.Bubble.List.Role(role="ai-markdown",
72
  placement="start"):
73
  with ms.Slot("avatar"):
 
75
  backgroundColor="#fde3cf")):
76
  with ms.Slot("icon"):
77
  antd.Icon("UserOutlined")
78
+ with ms.Slot("contentRender",
79
  params_mapping="(content) => content"):
80
  ms.Markdown()
81
  with antdx.Bubble.List.Role(role="ai-error-message",
 
85
  backgroundColor="#fde3cf")):
86
  with ms.Slot("icon"):
87
  antd.Icon("UserOutlined")
88
+ with ms.Slot("contentRender",
89
  params_mapping="(content) => content"):
90
  antd.Typography.Text(type="danger")
91
+ with antdx.Bubble.List.Role(role="ai-suggestion",
92
+ placement="start",
93
+ variant="borderless"):
94
+ with ms.Slot("contentRender",
 
 
95
  params_mapping="(items) => ({ items })"):
96
  prompts = antdx.Prompts(vertical=True)
97
 
98
+ with antdx.Bubble.List.Role(role="ai-file",
99
+ placement="start",
100
+ variant="borderless"):
101
+ with ms.Slot("contentRender",
 
 
102
  params_mapping="""(content) => {
103
  return {
104
+ each: content
105
  }
106
  }"""):
107
  with antd.Flex(vertical=True, gap="middle"):
108
  with ms.Each(as_item="each"):
109
+ antdx.FileCard()
110
 
111
  if __name__ == "__main__":
112
  demo.queue().launch()
components/antdx/bubble/demos/typing_effect.py CHANGED
@@ -28,13 +28,16 @@ with gr.Blocks() as demo:
28
  with antd.Flex(vertical=True, gap="small"):
29
  with antdx.Bubble(content=text,
30
  typing=dict(step=2, interval=50)) as bubble1:
31
- with ms.Slot("avatar.icon"):
32
- antd.Icon("UserOutlined")
 
 
33
  with antdx.Bubble(content=text,
34
- typing=dict(step=2, interval=50,
35
- suffix="💗")) as bubble2:
36
- with ms.Slot("avatar.icon"):
37
- antd.Icon("UserOutlined")
 
38
  btn = antd.Button("Repeat 1 Times",
39
  elem_style=dict(alignSelf="flex-end"))
40
  btn.click(fn=repeat,
 
28
  with antd.Flex(vertical=True, gap="small"):
29
  with antdx.Bubble(content=text,
30
  typing=dict(step=2, interval=50)) as bubble1:
31
+ with ms.Slot("avatar"):
32
+ with antd.Avatar():
33
+ with ms.Slot("icon"):
34
+ antd.Icon("UserOutlined")
35
  with antdx.Bubble(content=text,
36
+ typing=dict(step=2, interval=50)) as bubble2:
37
+ with ms.Slot("avatar"):
38
+ with antd.Avatar():
39
+ with ms.Slot("icon"):
40
+ antd.Icon("UserOutlined")
41
  btn = antd.Button("Repeat 1 Times",
42
  elem_style=dict(alignSelf="flex-end"))
43
  btn.click(fn=repeat,
components/antdx/bubble/demos/variant.py CHANGED
@@ -11,18 +11,27 @@ with gr.Blocks() as demo:
11
  )
12
  with antd.Flex(vertical=True, gap="middle"):
13
  with antdx.Bubble(variant="filled", content="variant: filled"):
14
- with ms.Slot("avatar.icon"):
15
- antd.Icon("UserOutlined")
 
 
16
  with antdx.Bubble(variant="outlined",
17
  content="variant: outlined"):
18
- with ms.Slot("avatar.icon"):
19
- antd.Icon("UserOutlined")
 
 
 
20
  with antdx.Bubble(variant="shadow", content="variant: shadow"):
21
- with ms.Slot("avatar.icon"):
22
- antd.Icon("UserOutlined")
 
 
23
  with antdx.Bubble(variant="borderless"):
24
- with ms.Slot("avatar.icon"):
25
- antd.Icon("UserOutlined")
 
 
26
  with ms.Slot("content"):
27
  with antdx.Prompts(
28
  vertical=True,
 
11
  )
12
  with antd.Flex(vertical=True, gap="middle"):
13
  with antdx.Bubble(variant="filled", content="variant: filled"):
14
+ with ms.Slot("avatar"):
15
+ with antd.Avatar():
16
+ with ms.Slot("icon"):
17
+ antd.Icon("UserOutlined")
18
  with antdx.Bubble(variant="outlined",
19
  content="variant: outlined"):
20
+
21
+ with ms.Slot("avatar"):
22
+ with antd.Avatar():
23
+ with ms.Slot("icon"):
24
+ antd.Icon("UserOutlined")
25
  with antdx.Bubble(variant="shadow", content="variant: shadow"):
26
+ with ms.Slot("avatar"):
27
+ with antd.Avatar():
28
+ with ms.Slot("icon"):
29
+ antd.Icon("UserOutlined")
30
  with antdx.Bubble(variant="borderless"):
31
+ with ms.Slot("avatar"):
32
+ with antd.Avatar():
33
+ with ms.Slot("icon"):
34
+ antd.Icon("UserOutlined")
35
  with ms.Slot("content"):
36
  with antdx.Prompts(
37
  vertical=True,
components/antdx/code_highlighter/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # CodeHighlighter
2
+
3
+ A component for syntax highlighting of code blocks. See [Ant Design X](https://x.ant.design/components/code-highlighter/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
components/antdx/code_highlighter/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # CodeHighlighter
2
+
3
+ A component for syntax highlighting of code blocks. See [Ant Design X](https://x.ant.design/components/code-highlighter/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
components/{legacy/Chatbot → antdx/code_highlighter}/app.py RENAMED
@@ -1,4 +1,4 @@
1
- from components.legacy.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
 
1
+ from helper.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
components/antdx/code_highlighter/demos/basic.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.antdx as antdx
4
+ import modelscope_studio.components.base as ms
5
+
6
+ python_code = """import gradio as gr
7
+ import modelscope_studio.components.antdx as antdx
8
+ import modelscope_studio.components.base as ms
9
+
10
+ with gr.Blocks() as demo:
11
+ with ms.Application():
12
+ with antdx.XProvider():
13
+ antdx.CodeHighlighter(
14
+ value="print('Hello, World!')",
15
+ lang="python",
16
+ header=True
17
+ )
18
+
19
+ if __name__ == "__main__":
20
+ demo.queue().launch()
21
+ """
22
+
23
+ javascript_code = """function greet(name) {
24
+ return `Hello, ${name}!`;
25
+ }
26
+
27
+ const result = greet('World');
28
+ console.log(result);
29
+ """
30
+
31
+ typescript_code = """interface User {
32
+ id: number;
33
+ name: string;
34
+ email: string;
35
+ }
36
+
37
+ function createUser(name: string, email: string): User {
38
+ return {
39
+ id: Math.random(),
40
+ name,
41
+ email,
42
+ };
43
+ }
44
+ """
45
+
46
+ with gr.Blocks() as demo:
47
+ with ms.Application():
48
+ with antdx.XProvider():
49
+ antd.Divider("Python Code")
50
+ antdx.CodeHighlighter(value=python_code,
51
+ lang="python",
52
+ header=True)
53
+
54
+ antd.Divider("JavaScript Code")
55
+ antdx.CodeHighlighter(value=javascript_code,
56
+ lang="javascript",
57
+ header=True)
58
+
59
+ antd.Divider("TypeScript Code")
60
+ antdx.CodeHighlighter(value=typescript_code,
61
+ lang="typescript",
62
+ header=True)
63
+
64
+ antd.Divider("Custom Header Slot")
65
+ with antdx.CodeHighlighter(value=python_code, lang="python"):
66
+ with ms.Slot("header"):
67
+ with antd.Flex(justify="space-between", align="center"):
68
+ ms.Span("Python Example")
69
+ with antd.Button(value=None, size="small",
70
+ type="text"):
71
+ with ms.Slot("icon"):
72
+ antd.Icon("CopyOutlined")
73
+
74
+ if __name__ == "__main__":
75
+ demo.queue().launch()
components/antdx/file_card/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # FileCard
2
+
3
+ Used to display files during conversations or input. See [Ant Design X](https://x.ant.design/components/file-card/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/file_card/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # FileCard
2
+
3
+ Used to display files during conversations or input. See [Ant Design X](https://x.ant.design/components/file-card/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/{legacy/Flow → antdx/file_card}/app.py RENAMED
@@ -1,4 +1,4 @@
1
- from components.legacy.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
 
1
+ from helper.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
components/antdx/file_card/demos/basic.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.antdx as antdx
4
+ import modelscope_studio.components.base as ms
5
+
6
+ with gr.Blocks() as demo:
7
+ with ms.Application():
8
+ with antdx.XProvider():
9
+ antd.Divider("File Types")
10
+ with antd.Flex(gap="middle", wrap=True):
11
+ antdx.FileCard(filename="document.pdf",
12
+ type="file",
13
+ icon="pdf",
14
+ byte=204800)
15
+ antdx.FileCard(filename="spreadsheet.xlsx",
16
+ type="file",
17
+ icon="excel",
18
+ byte=102400)
19
+ antdx.FileCard(filename="presentation.pptx",
20
+ type="file",
21
+ icon="ppt",
22
+ byte=512000)
23
+ antdx.FileCard(filename="report.docx",
24
+ type="file",
25
+ icon="word",
26
+ byte=81920)
27
+ antdx.FileCard(filename="archive.zip",
28
+ type="file",
29
+ icon="zip",
30
+ byte=1048576)
31
+ antdx.FileCard(filename="README.md",
32
+ type="file",
33
+ icon="markdown",
34
+ byte=4096)
35
+ antdx.FileCard(filename="script.py",
36
+ type="file",
37
+ icon="python",
38
+ byte=8192)
39
+
40
+ antd.Divider("Image Type")
41
+ with antd.Flex(gap="middle", wrap=True):
42
+ antdx.FileCard(
43
+ filename="photo.jpg",
44
+ type="image",
45
+ src=
46
+ "https://gw.alipayobjects.com/zos/antfincdn/aPkFc8Sj7n/method-draw-image.svg",
47
+ byte=327680)
48
+
49
+ antd.Divider("Loading State")
50
+ with antd.Flex(gap="middle", wrap=True):
51
+ antdx.FileCard(filename="loading-file.pdf",
52
+ type="file",
53
+ icon="pdf",
54
+ loading=True)
55
+
56
+ antd.Divider("With Description")
57
+ with antd.Flex(gap="middle", wrap=True):
58
+ antdx.FileCard(filename="notes.txt",
59
+ type="file",
60
+ description="Last modified today",
61
+ byte=2048)
62
+
63
+ antd.Divider("FileCard.List")
64
+ antdx.FileCard.List(items=[{
65
+ "filename": "file1.pdf",
66
+ "type": "file",
67
+ "icon": "pdf",
68
+ "byte": 204800
69
+ }, {
70
+ "filename": "image1.jpg",
71
+ "type": "image",
72
+ "byte": 327680
73
+ }, {
74
+ "filename": "audio.mp3",
75
+ "type": "audio",
76
+ "byte": 5242880
77
+ }, {
78
+ "filename": "video.mp4",
79
+ "type": "video",
80
+ "byte": 52428800
81
+ }],
82
+ removable=True)
83
+
84
+ antd.Divider("FileCard.List with Custom Items")
85
+ with antdx.FileCard.List(removable=True):
86
+ antdx.FileCard.List.Item(filename="custom1.xlsx",
87
+ type="file",
88
+ icon="excel",
89
+ byte=102400)
90
+ antdx.FileCard.List.Item(filename="custom2.pdf",
91
+ type="file",
92
+ icon="pdf",
93
+ byte=204800)
94
+
95
+ if __name__ == "__main__":
96
+ demo.queue().launch()
components/antdx/folder/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Folder
2
+
3
+ A folder tree component for displaying file structures. See [Ant Design X](https://x.ant.design/components/folder/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/folder/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Folder
2
+
3
+ A folder tree component for displaying file structures. See [Ant Design X](https://x.ant.design/components/folder/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/{legacy/Lifecycle → antdx/folder}/app.py RENAMED
@@ -1,4 +1,4 @@
1
- from components.legacy.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
 
1
+ from helper.Docs import Docs
2
 
3
  docs = Docs(__file__)
4
 
components/antdx/folder/demos/basic.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.antdx as antdx
4
+ import modelscope_studio.components.base as ms
5
+
6
+
7
+ def on_file_click(e: gr.EventData):
8
+ print("file clicked:", e._data["payload"])
9
+
10
+
11
+ def on_folder_click(e: gr.EventData):
12
+ print("folder clicked:", e._data["payload"])
13
+
14
+
15
+ def on_selected_file_change(e: gr.EventData):
16
+ print("selected file changed:", e._data["payload"])
17
+
18
+
19
+ with gr.Blocks() as demo:
20
+ with ms.Application():
21
+ with antdx.XProvider():
22
+ antd.Divider("Basic Folder Tree")
23
+ with antdx.Folder(default_expand_all=True) as folder1:
24
+ with antdx.Folder.TreeNode(title="src", path="/src"):
25
+ antdx.Folder.TreeNode(title="index.ts",
26
+ path="/src/index.ts",
27
+ content="export * from './app';")
28
+ antdx.Folder.TreeNode(
29
+ title="app.ts",
30
+ path="/src/app.ts",
31
+ content=
32
+ "// Application entry point\nconsole.log('Hello World');"
33
+ )
34
+ with antdx.Folder.TreeNode(title="components",
35
+ path="/src/components"):
36
+ antdx.Folder.TreeNode(
37
+ title="Button.tsx",
38
+ path="/src/components/Button.tsx",
39
+ content=
40
+ "import React from 'react';\n\nexport const Button = () => <button>Click me</button>;"
41
+ )
42
+ antdx.Folder.TreeNode(
43
+ title="Input.tsx",
44
+ path="/src/components/Input.tsx",
45
+ content=
46
+ "import React from 'react';\n\nexport const Input = () => <input />;"
47
+ )
48
+ with antdx.Folder.TreeNode(title="utils",
49
+ path="/src/utils"):
50
+ antdx.Folder.TreeNode(
51
+ title="helpers.ts",
52
+ path="/src/utils/helpers.ts",
53
+ content=
54
+ "export const add = (a: number, b: number) => a + b;"
55
+ )
56
+ antdx.Folder.TreeNode(
57
+ title="package.json",
58
+ path="/package.json",
59
+ content=
60
+ '{\n "name": "my-project",\n "version": "1.0.0"\n}')
61
+ antdx.Folder.TreeNode(
62
+ title="README.md",
63
+ path="/README.md",
64
+ content="# My Project\n\nA sample project.")
65
+
66
+ antd.Divider("Using tree_data Prop")
67
+ antdx.Folder(
68
+ default_expand_all=True,
69
+ tree_data=[{
70
+ "title":
71
+ "project",
72
+ "path":
73
+ "/project",
74
+ "children": [{
75
+ "title": "main.py",
76
+ "path": "/project/main.py",
77
+ "content": "print('Hello, World!')"
78
+ }, {
79
+ "title":
80
+ "utils.py",
81
+ "path":
82
+ "/project/utils.py",
83
+ "content":
84
+ "def greet(name):\n return f'Hello, {name}!'"
85
+ }, {
86
+ "title":
87
+ "tests",
88
+ "path":
89
+ "/project/tests",
90
+ "children": [{
91
+ "title":
92
+ "test_main.py",
93
+ "path":
94
+ "/project/tests/test_main.py",
95
+ "content":
96
+ "import unittest\n\nclass TestMain(unittest.TestCase):\n pass"
97
+ }]
98
+ }]
99
+ }, {
100
+ "title": "requirements.txt",
101
+ "path": "/requirements.txt",
102
+ "content": "gradio\nmodelscope-studio"
103
+ }])
104
+
105
+ folder1.file_click(fn=on_file_click)
106
+ folder1.folder_click(fn=on_folder_click)
107
+ folder1.selected_file_change(fn=on_selected_file_change)
108
+
109
+ if __name__ == "__main__":
110
+ demo.queue().launch()
components/antdx/mermaid/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Mermaid
2
+
3
+ A Mermaid diagram rendering component. See [Ant Design X](https://x.ant.design/components/mermaid/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/mermaid/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Mermaid
2
+
3
+ A Mermaid diagram rendering component. See [Ant Design X](https://x.ant.design/components/mermaid/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/mermaid/app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from helper.Docs import Docs
2
+
3
+ docs = Docs(__file__)
4
+
5
+ if __name__ == "__main__":
6
+ docs.render().queue().launch()
components/{legacy/Markdown/demos/custom_tags/accordion → antdx/mermaid/demos}/basic.py RENAMED
@@ -1,17 +1,14 @@
1
  import gradio as gr
 
2
  import modelscope_studio.components.base as ms
3
- import modelscope_studio.components.legacy as mgr
4
 
5
- with gr.Blocks() as demo, ms.Application():
6
- mgr.Markdown("""
7
- <accordion title="Using tool">
8
-
9
- ```json
10
- {"text": "glorious weather", "resolution": "1024*1024"}
11
- ```
12
-
13
- </accordion>
14
- """)
15
 
16
  if __name__ == "__main__":
17
  demo.queue().launch()
 
1
  import gradio as gr
2
+ import modelscope_studio.components.antdx as antdx
3
  import modelscope_studio.components.base as ms
 
4
 
5
+ with gr.Blocks() as demo:
6
+ with ms.Application():
7
+ with antdx.XProvider():
8
+ antdx.Mermaid(value="""graph TD
9
+ A[Start] --> B{Decision}
10
+ B -->|Yes| C[OK]
11
+ B -->|No| D[Cancel]""")
 
 
 
12
 
13
  if __name__ == "__main__":
14
  demo.queue().launch()
components/antdx/notification/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Notification
2
+
3
+ A browser native notification component. See [Ant Design X](https://x.ant.design/components/notification/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/notification/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Notification
2
+
3
+ A browser native notification component. See [Ant Design X](https://x.ant.design/components/notification/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic" position="bottom" collapsible="true"></demo>
components/antdx/notification/app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from helper.Docs import Docs
2
+
3
+ docs = Docs(__file__)
4
+
5
+ if __name__ == "__main__":
6
+ docs.render().queue().launch()
components/antdx/notification/demos/basic.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.antdx as antdx
4
+ import modelscope_studio.components.base as ms
5
+
6
+ with gr.Blocks() as demo:
7
+ with ms.Application():
8
+ with antdx.XProvider():
9
+ notification = antdx.Notification(
10
+ title="Hello Notification",
11
+ body=
12
+ "This is a browser native notification triggered from Gradio.",
13
+ duration=5000,
14
+ visible=False)
15
+ btn = antd.Button("Send Notification", type="primary")
16
+
17
+ btn.click(
18
+ fn=lambda: gr.update(visible=True),
19
+ outputs=[notification],
20
+ )
21
+
22
+ if __name__ == "__main__":
23
+ demo.queue().launch()
components/antdx/prompts/demos/nest_usage.py CHANGED
@@ -11,7 +11,7 @@ def item_click(e: gr.EventData):
11
 
12
  with gr.Blocks() as demo:
13
  with ms.Application():
14
- with antdx.XProvider(theme=dict(algorithm=dict(dark=False))):
15
  with antd.Card(elem_style=dict(borderRadius=0, border=0)):
16
  with antdx.Prompts(
17
  title="Do you want?",
 
11
 
12
  with gr.Blocks() as demo:
13
  with ms.Application():
14
+ with antdx.XProvider(theme_config=dict(algorithm=dict(dark=False))):
15
  with antd.Card(elem_style=dict(borderRadius=0, border=0)):
16
  with antdx.Prompts(
17
  title="Do you want?",
components/antdx/sources/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Sources
2
+
3
+ A component for displaying information source lists in AI chat scenarios. See [Ant Design X](https://x.ant.design/components/sources/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
components/antdx/sources/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Sources
2
+
3
+ A component for displaying information source lists in AI chat scenarios. See [Ant Design X](https://x.ant.design/components/sources/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
components/antdx/sources/app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from helper.Docs import Docs
2
+
3
+ docs = Docs(__file__)
4
+
5
+ if __name__ == "__main__":
6
+ docs.render().queue().launch()
components/antdx/sources/demos/basic.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modelscope_studio.components.antd as antd
3
+ import modelscope_studio.components.antdx as antdx
4
+ import modelscope_studio.components.base as ms
5
+
6
+
7
+ def on_click(e: gr.EventData):
8
+ item = e._data["payload"][0]
9
+ gr.Info("Clicked: " + str(item.get("title", "")))
10
+
11
+
12
+ def on_expand(e: gr.EventData):
13
+ expanded = e._data["payload"][0]
14
+ gr.Info("Expanded: " + str(expanded))
15
+
16
+
17
+ source_items = [
18
+ {
19
+ "title": "Ant Design X",
20
+ "description": "The AI-Native UI solution of Ant Design",
21
+ "href": "https://x.ant.design",
22
+ },
23
+ {
24
+ "title": "Ant Design",
25
+ "description": "An enterprise-class UI design language",
26
+ "href": "https://ant.design",
27
+ },
28
+ {
29
+ "title": "GitHub",
30
+ "description": "Where the world builds software",
31
+ "href": "https://github.com",
32
+ },
33
+ ]
34
+
35
+ with gr.Blocks() as demo:
36
+ with ms.Application():
37
+ with antdx.XProvider():
38
+ antd.Divider("Basic Sources")
39
+ sources1 = antdx.Sources(title="References",
40
+ items=source_items,
41
+ default_expanded=True)
42
+
43
+ antd.Divider("Inline Sources")
44
+ sources2 = antdx.Sources(title="References",
45
+ items=source_items,
46
+ inline=True)
47
+
48
+ antd.Divider("Sources with Slot Items")
49
+ with antdx.Sources(title="Sources") as sources3:
50
+ with ms.Slot("items"):
51
+ antdx.Sources.Item(title="Ant Design X",
52
+ description="The AI-Native UI solution",
53
+ url="https://x.ant.design")
54
+ antdx.Sources.Item(
55
+ title="ModelScope Studio",
56
+ description="Gradio component library",
57
+ url="https://github.com/modelscope/modelscope-studio")
58
+
59
+ sources1.click(fn=on_click)
60
+ sources2.click(fn=on_click)
61
+ sources1.expand(fn=on_expand)
62
+
63
+ if __name__ == "__main__":
64
+ demo.queue().launch()
components/antdx/think/README-zh_CN.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Think
2
+
3
+ A component for displaying AI model thinking process in chat scenarios. See [Ant Design X](https://x.ant.design/components/think/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>
components/antdx/think/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Think
2
+
3
+ A component for displaying AI model thinking process in chat scenarios. See [Ant Design X](https://x.ant.design/components/think/) for more information.
4
+
5
+ ## Examples
6
+
7
+ <demo name="basic"></demo>