Spaces:
Running
Running
feat: add antdx
Browse files- app.py +32 -8
- components/antdx/attachments/README-zh_CN.md +1 -0
- components/antdx/attachments/README.md +1 -0
- components/antdx/attachments/demos/combination.py +2 -2
- components/antdx/attachments/demos/file_card.py +71 -0
- components/antdx/bubble/demos/chatbot.py +2 -2
- components/antdx/bubble/demos/typing_effect.py +7 -3
- components/antdx/sender/README-zh_CN.md +9 -0
- components/antdx/sender/README.md +9 -0
- components/antdx/sender/app.py +6 -0
- components/antdx/sender/demos/basic.py +27 -0
- components/antdx/sender/demos/header_panel.py +77 -0
- components/antdx/sender/demos/submit_type.py +27 -0
- components/antdx/suggestion/README-zh_CN.md +9 -0
- components/antdx/suggestion/README.md +9 -0
- components/antdx/suggestion/app.py +6 -0
- components/antdx/suggestion/demos/basic.py +43 -0
- components/antdx/suggestion/demos/block.py +58 -0
- components/antdx/suggestion/demos/controlled_by_python.py +54 -0
- components/antdx/thought_chain/README-zh_CN.md +9 -0
- components/antdx/thought_chain/README.md +9 -0
- components/antdx/thought_chain/app.py +6 -0
- components/antdx/thought_chain/demos/basic.py +76 -0
- components/antdx/thought_chain/demos/item_status.py +70 -0
- components/antdx/thought_chain/demos/nested_use.py +67 -0
- components/antdx/x_provider/README-zh_CN.md +18 -0
- components/antdx/x_provider/README.md +18 -0
- components/antdx/x_provider/app.py +6 -0
- components/base/application/demos/language_adaptation.py +8 -2
- requirements.txt +1 -1
- src/pyproject.toml +1 -1
app.py
CHANGED
@@ -66,7 +66,7 @@ index_docs = {"overview": Docs(__file__), **layout_templates}
|
|
66 |
|
67 |
base_docs = get_docs("base")
|
68 |
antd_docs = get_docs("antd")
|
69 |
-
|
70 |
|
71 |
default_active_tab = "index"
|
72 |
index_menu_items = [{
|
@@ -419,6 +419,30 @@ antdx_menu_items = [{
|
|
419 |
"children": [{
|
420 |
"label": get_text("Attachments", "Attachments 输入附件"),
|
421 |
"key": "attachments"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
}]
|
423 |
}]
|
424 |
|
@@ -474,12 +498,12 @@ tabs = [
|
|
474 |
"menus": antd_menu_items,
|
475 |
"extra_menu_footer": more_components
|
476 |
},
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
{
|
484 |
"label": get_text("Version 0.x", "0.x 版本"),
|
485 |
"key": "legacy",
|
@@ -493,7 +517,7 @@ site = Site(
|
|
493 |
# match the key of tabs
|
494 |
"index": index_docs,
|
495 |
"antd": antd_docs,
|
496 |
-
|
497 |
"base": base_docs
|
498 |
},
|
499 |
default_active_tab=default_active_tab,
|
|
|
66 |
|
67 |
base_docs = get_docs("base")
|
68 |
antd_docs = get_docs("antd")
|
69 |
+
antdx_docs = get_docs("antdx")
|
70 |
|
71 |
default_active_tab = "index"
|
72 |
index_menu_items = [{
|
|
|
419 |
"children": [{
|
420 |
"label": get_text("Attachments", "Attachments 输入附件"),
|
421 |
"key": "attachments"
|
422 |
+
}, {
|
423 |
+
"label": get_text("Sender", "Sender 输入框"),
|
424 |
+
"key": "sender"
|
425 |
+
}, {
|
426 |
+
"label": get_text("Suggestion", "Suggestion 快捷指令"),
|
427 |
+
"key": "suggestion"
|
428 |
+
}]
|
429 |
+
}, {
|
430 |
+
"label":
|
431 |
+
get_text("Confirm", "确认"),
|
432 |
+
"type":
|
433 |
+
"group",
|
434 |
+
"children": [{
|
435 |
+
"label": get_text("ThoughtChain", "ThoughtChain 思考链"),
|
436 |
+
"key": "thought_chain"
|
437 |
+
}]
|
438 |
+
}, {
|
439 |
+
"label":
|
440 |
+
get_text("Tools", "工具"),
|
441 |
+
"type":
|
442 |
+
"group",
|
443 |
+
"children": [{
|
444 |
+
"label": get_text("XProvider", "XProvider 全局化配置"),
|
445 |
+
"key": "x_provider"
|
446 |
}]
|
447 |
}]
|
448 |
|
|
|
498 |
"menus": antd_menu_items,
|
499 |
"extra_menu_footer": more_components
|
500 |
},
|
501 |
+
{
|
502 |
+
"label": get_text("Antdx Components", "Antdx 组件"),
|
503 |
+
"key": "antdx",
|
504 |
+
"default_active_key": "overview",
|
505 |
+
"menus": antdx_menu_items,
|
506 |
+
},
|
507 |
{
|
508 |
"label": get_text("Version 0.x", "0.x 版本"),
|
509 |
"key": "legacy",
|
|
|
517 |
# match the key of tabs
|
518 |
"index": index_docs,
|
519 |
"antd": antd_docs,
|
520 |
+
"antdx": antdx_docs,
|
521 |
"base": base_docs
|
522 |
},
|
523 |
default_active_tab=default_active_tab,
|
components/antdx/attachments/README-zh_CN.md
CHANGED
@@ -6,3 +6,4 @@ 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>
|
|
|
|
6 |
|
7 |
<demo name="basic"></demo>
|
8 |
<demo name="combination" title="Combination"></demo>
|
9 |
+
<demo name="file_card" title="File Card"></demo>
|
components/antdx/attachments/README.md
CHANGED
@@ -6,3 +6,4 @@ 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>
|
|
|
|
6 |
|
7 |
<demo name="basic"></demo>
|
8 |
<demo name="combination" title="Combination"></demo>
|
9 |
+
<demo name="file_card" title="File Card"></demo>
|
components/antdx/attachments/demos/combination.py
CHANGED
@@ -17,7 +17,7 @@ def submit(sender_value, attachments_value):
|
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
-
state = gr.State({"open":
|
21 |
with ms.Application():
|
22 |
with antdx.XProvider():
|
23 |
antd.Typography.Paragraph(
|
@@ -31,7 +31,7 @@ with gr.Blocks() as demo:
|
|
31 |
antd.Icon("LinkOutlined")
|
32 |
with ms.Slot("header"):
|
33 |
with antdx.Sender.Header(title="Attachments",
|
34 |
-
open=
|
35 |
styles={
|
36 |
"content": {
|
37 |
"padding": 0,
|
|
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
+
state = gr.State({"open": False})
|
21 |
with ms.Application():
|
22 |
with antdx.XProvider():
|
23 |
antd.Typography.Paragraph(
|
|
|
31 |
antd.Icon("LinkOutlined")
|
32 |
with ms.Slot("header"):
|
33 |
with antdx.Sender.Header(title="Attachments",
|
34 |
+
open=False,
|
35 |
styles={
|
36 |
"content": {
|
37 |
"padding": 0,
|
components/antdx/attachments/demos/file_card.py
CHANGED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/chatbot.py
CHANGED
@@ -67,7 +67,7 @@ with gr.Blocks() as demo:
|
|
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="
|
71 |
# Define Roles
|
72 |
with ms.Slot("roles"):
|
73 |
with antdx.Bubble.List.Role(
|
@@ -141,7 +141,7 @@ with gr.Blocks() as demo:
|
|
141 |
outputs=[state, bubble_list])
|
142 |
scroll_btn.click(fn=None,
|
143 |
js="""() => {
|
144 |
-
const bubbleList = document.getElementById("
|
145 |
bubbleList.scrollTo({ top:0, behavior:'smooth' });
|
146 |
}""")
|
147 |
|
|
|
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(
|
|
|
141 |
outputs=[state, bubble_list])
|
142 |
scroll_btn.click(fn=None,
|
143 |
js="""() => {
|
144 |
+
const bubbleList = document.getElementById("chatbot");
|
145 |
bubbleList.scrollTo({ top:0, behavior:'smooth' });
|
146 |
}""")
|
147 |
|
components/antdx/bubble/demos/typing_effect.py
CHANGED
@@ -11,16 +11,20 @@ def repeat(state_value):
|
|
11 |
state_value["repeat"] = state_value["repeat"] + 1
|
12 |
else:
|
13 |
state_value["repeat"] = 1
|
|
|
14 |
return gr.update(value=state_value), gr.update(
|
15 |
-
value=f"Repeat {
|
16 |
-
content=text *
|
|
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
state = gr.State({"repeat": 1})
|
21 |
with ms.Application():
|
22 |
with antdx.XProvider():
|
23 |
-
antd.Typography.Paragraph(
|
|
|
|
|
24 |
with antd.Flex(vertical=True, gap="small"):
|
25 |
with antdx.Bubble(content=text,
|
26 |
typing=dict(step=2, interval=50)) as bubble1:
|
|
|
11 |
state_value["repeat"] = state_value["repeat"] + 1
|
12 |
else:
|
13 |
state_value["repeat"] = 1
|
14 |
+
repeat_value = state_value["repeat"]
|
15 |
return gr.update(value=state_value), gr.update(
|
16 |
+
value=f"Repeat {repeat_value} Times"), gr.update(
|
17 |
+
content=text * repeat_value), gr.update(content=text *
|
18 |
+
repeat_value)
|
19 |
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
state = gr.State({"repeat": 1})
|
23 |
with ms.Application():
|
24 |
with antdx.XProvider():
|
25 |
+
antd.Typography.Paragraph(
|
26 |
+
"Enable typing output by setting the typing prop. If the updated content is a subset of the previous content, it will continue to output, otherwise it will output again."
|
27 |
+
)
|
28 |
with antd.Flex(vertical=True, gap="small"):
|
29 |
with antdx.Bubble(content=text,
|
30 |
typing=dict(step=2, interval=50)) as bubble1:
|
components/antdx/sender/README-zh_CN.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Sender
|
2 |
+
|
3 |
+
A input component for chat. See [Ant Design X](https://x.ant.design/components/sender/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="submit_type" title="Submit Type"></demo>
|
9 |
+
<demo name="header_panel" title="Header Panel"></demo>
|
components/antdx/sender/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Sender
|
2 |
+
|
3 |
+
A input component for chat. See [Ant Design X](https://x.ant.design/components/sender/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="submit_type" title="Submit Type"></demo>
|
9 |
+
<demo name="header_panel" title="Header Panel"></demo>
|
components/antdx/sender/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/sender/demos/basic.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 submit():
|
8 |
+
return gr.update(loading=True, read_only=True)
|
9 |
+
|
10 |
+
|
11 |
+
def cancel():
|
12 |
+
return gr.update(loading=False, read_only=False)
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
with ms.Application():
|
17 |
+
with antdx.XProvider():
|
18 |
+
with antd.Flex(vertical=True, gap="middle"):
|
19 |
+
sender = antdx.Sender()
|
20 |
+
antdx.Sender("Force as loading", loading=True, read_only=True)
|
21 |
+
antdx.Sender("Set to disabled", disabled=True)
|
22 |
+
|
23 |
+
sender.submit(fn=submit, outputs=[sender])
|
24 |
+
sender.cancel(fn=cancel, outputs=[sender])
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.queue().launch()
|
components/antdx/sender/demos/header_panel.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 paste_file(attachments_value, e: gr.EventData):
|
8 |
+
return gr.update(value=attachments_value + e._data["payload"][0])
|
9 |
+
|
10 |
+
|
11 |
+
def toggle_open(state_value):
|
12 |
+
state_value["open"] = not state_value["open"]
|
13 |
+
return gr.update(open=state_value["open"]), gr.update(value=state_value)
|
14 |
+
|
15 |
+
|
16 |
+
def submit(sender_value, attachments_value):
|
17 |
+
print(sender_value, attachments_value)
|
18 |
+
return gr.update(value=None), gr.update(value=None)
|
19 |
+
|
20 |
+
|
21 |
+
with gr.Blocks() as demo:
|
22 |
+
state = gr.State({"open": False})
|
23 |
+
with ms.Application():
|
24 |
+
with antdx.XProvider():
|
25 |
+
antd.Typography.Paragraph(
|
26 |
+
"Use header to customize the file upload example and paste image to upload files with Attachments."
|
27 |
+
)
|
28 |
+
with antdx.Sender(placeholder="← Click to open") as sender:
|
29 |
+
with ms.Slot("prefix"):
|
30 |
+
with antd.Button(value=None, type="text") as prefix_button:
|
31 |
+
with ms.Slot("icon"):
|
32 |
+
antd.Icon("LinkOutlined")
|
33 |
+
with ms.Slot("header"):
|
34 |
+
with antdx.Sender.Header(title="Attachments",
|
35 |
+
open=False,
|
36 |
+
styles={
|
37 |
+
"content": {
|
38 |
+
"padding": 0,
|
39 |
+
},
|
40 |
+
}) as sender_header:
|
41 |
+
with antdx.Attachments() as attachments:
|
42 |
+
with ms.Slot(
|
43 |
+
"placeholder.title",
|
44 |
+
params_mapping=
|
45 |
+
"""(type) => type === 'drop' ? 'Drop file here' : 'Upload files'"""
|
46 |
+
):
|
47 |
+
ms.Span()
|
48 |
+
with ms.Slot(
|
49 |
+
"placeholder.description",
|
50 |
+
params_mapping=
|
51 |
+
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })"
|
52 |
+
):
|
53 |
+
ms.Span(
|
54 |
+
"Click or drag files to this area to upload"
|
55 |
+
)
|
56 |
+
with ms.Slot(
|
57 |
+
"placeholder.icon",
|
58 |
+
params_mapping=
|
59 |
+
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })"
|
60 |
+
):
|
61 |
+
antd.Icon("CloudUploadOutlined")
|
62 |
+
|
63 |
+
sender_header.open_change(fn=toggle_open,
|
64 |
+
inputs=[state],
|
65 |
+
outputs=[sender_header, state])
|
66 |
+
prefix_button.click(fn=toggle_open,
|
67 |
+
inputs=[state],
|
68 |
+
outputs=[sender_header, state])
|
69 |
+
sender.submit(fn=submit,
|
70 |
+
inputs=[sender, attachments],
|
71 |
+
outputs=[sender, attachments])
|
72 |
+
sender.paste_file(fn=paste_file,
|
73 |
+
inputs=[attachments],
|
74 |
+
outputs=[attachments])
|
75 |
+
|
76 |
+
if __name__ == "__main__":
|
77 |
+
demo.queue().launch()
|
components/antdx/sender/demos/submit_type.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 submit():
|
8 |
+
return gr.update(loading=True, read_only=True)
|
9 |
+
|
10 |
+
|
11 |
+
def cancel():
|
12 |
+
return gr.update(loading=False, read_only=False)
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
with ms.Application():
|
17 |
+
with antdx.XProvider():
|
18 |
+
with antd.Flex(vertical=True, gap="middle"):
|
19 |
+
sender = antdx.Sender(
|
20 |
+
submit_type="shiftEnter",
|
21 |
+
placeholder="Press Shift + Enter to send message")
|
22 |
+
|
23 |
+
sender.submit(fn=submit, outputs=[sender])
|
24 |
+
sender.cancel(fn=cancel, outputs=[sender])
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.queue().launch()
|
components/antdx/suggestion/README-zh_CN.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Suggestion
|
2 |
+
|
3 |
+
A suggestion component for chat. See [Ant Design X](https://x.ant.design/components/suggestion/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="block" title="Block"></demo>
|
9 |
+
<demo name="controlled_by_python" title="Controlled By Python"></demo>
|
components/antdx/suggestion/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Suggestion
|
2 |
+
|
3 |
+
A suggestion component for chat. See [Ant Design X](https://x.ant.design/components/suggestion/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="block" title="Block"></demo>
|
9 |
+
<demo name="controlled_by_python" title="Controlled By Python"></demo>
|
components/antdx/suggestion/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/suggestion/demos/basic.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 select_suggestion(e: gr.EventData):
|
8 |
+
return gr.update(value=e._data["payload"][0])
|
9 |
+
|
10 |
+
|
11 |
+
with gr.Blocks() as demo:
|
12 |
+
with ms.Application():
|
13 |
+
with antdx.XProvider():
|
14 |
+
with antdx.Suggestion(
|
15 |
+
# onKeyDown Handler in Javascript
|
16 |
+
should_trigger="""(e, { onTrigger, onKeyDown }) => {
|
17 |
+
const value = e.target.value
|
18 |
+
if (value === '/') {
|
19 |
+
onTrigger()
|
20 |
+
} else if (!value) {
|
21 |
+
onTrigger(false);
|
22 |
+
}
|
23 |
+
onKeyDown(e)
|
24 |
+
}""") as suggestion:
|
25 |
+
with ms.Slot("items"):
|
26 |
+
antdx.Suggestion.Item(label="Write a report",
|
27 |
+
value="report")
|
28 |
+
antdx.Suggestion.Item(label="Draw a picture", value="draw")
|
29 |
+
with antdx.Suggestion.Item(label="Check some knowledge",
|
30 |
+
value="knowledge"):
|
31 |
+
with ms.Slot("icon"):
|
32 |
+
antd.Icon("OpenAIFilled")
|
33 |
+
antdx.Suggestion.Item(label="About React",
|
34 |
+
value="react")
|
35 |
+
antdx.Suggestion.Item(label="About Ant Design",
|
36 |
+
value="antd")
|
37 |
+
with ms.Slot("children"):
|
38 |
+
sender = antdx.Sender(
|
39 |
+
placeholder="Enter / to get suggestions")
|
40 |
+
suggestion.select(fn=select_suggestion, outputs=[sender])
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
demo.queue().launch()
|
components/antdx/suggestion/demos/block.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
items = [
|
7 |
+
{
|
8 |
+
"label": 'Write a report',
|
9 |
+
"value": 'report'
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"label": 'Draw a picture',
|
13 |
+
"value": 'draw'
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"label": 'Check some knowledge',
|
17 |
+
"value": 'knowledge',
|
18 |
+
"extra": 'Extra Info',
|
19 |
+
},
|
20 |
+
]
|
21 |
+
|
22 |
+
|
23 |
+
def select_suggestion(e: gr.EventData):
|
24 |
+
return gr.update(value=e._data["payload"][0])
|
25 |
+
|
26 |
+
|
27 |
+
with gr.Blocks() as demo:
|
28 |
+
with ms.Application():
|
29 |
+
with antdx.XProvider():
|
30 |
+
antd.Typography.Paragraph(
|
31 |
+
"Set `block` to display in a whole row. ``extra` can be used to configure additional information."
|
32 |
+
)
|
33 |
+
with antdx.Suggestion(
|
34 |
+
items=items,
|
35 |
+
block=True,
|
36 |
+
# onKeyDown Handler in Javascript
|
37 |
+
should_trigger="""(e, { onTrigger, onKeyDown }) => {
|
38 |
+
switch(e.key) {
|
39 |
+
case '/':
|
40 |
+
onTrigger()
|
41 |
+
break
|
42 |
+
case 'ArrowRight':
|
43 |
+
case 'ArrowLeft':
|
44 |
+
case 'ArrowUp':
|
45 |
+
case 'ArrowDown':
|
46 |
+
break;
|
47 |
+
default:
|
48 |
+
onTrigger(false)
|
49 |
+
}
|
50 |
+
onKeyDown(e)
|
51 |
+
}""") as suggestion:
|
52 |
+
with ms.Slot("children"):
|
53 |
+
sender = antdx.Sender(
|
54 |
+
placeholder="Enter / to get suggestions")
|
55 |
+
suggestion.select(fn=select_suggestion, outputs=[sender])
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.queue().launch()
|
components/antdx/suggestion/demos/controlled_by_python.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import modelscope_studio.components.antdx as antdx
|
3 |
+
import modelscope_studio.components.base as ms
|
4 |
+
|
5 |
+
items = [
|
6 |
+
{
|
7 |
+
"label": 'Write a report',
|
8 |
+
"value": 'report'
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"label": 'Draw a picture',
|
12 |
+
"value": 'draw'
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"label": 'Check some knowledge',
|
16 |
+
"value": 'knowledge',
|
17 |
+
"extra": 'Extra Info',
|
18 |
+
},
|
19 |
+
]
|
20 |
+
|
21 |
+
|
22 |
+
def select_suggestion(e: gr.EventData):
|
23 |
+
return gr.update(value=e._data["payload"][0]), gr.update(open=False)
|
24 |
+
|
25 |
+
|
26 |
+
def change_sender(sender_value: str):
|
27 |
+
splitted_value = sender_value.split("/")
|
28 |
+
command = sender_value.split("/")[-1]
|
29 |
+
if len(splitted_value) > 1:
|
30 |
+
filtered_items = [
|
31 |
+
item for item in items
|
32 |
+
if item["label"].upper().find(command.upper()) != -1
|
33 |
+
and not command.startswith(item["value"])
|
34 |
+
]
|
35 |
+
if len(filtered_items) > 0:
|
36 |
+
return gr.update(open=True, items=filtered_items)
|
37 |
+
return gr.update(open=False)
|
38 |
+
|
39 |
+
|
40 |
+
with gr.Blocks() as demo:
|
41 |
+
with ms.Application():
|
42 |
+
with antdx.XProvider():
|
43 |
+
with antdx.Suggestion(open=False) as suggestion:
|
44 |
+
with ms.Slot("children"):
|
45 |
+
sender = antdx.Sender(
|
46 |
+
placeholder="Enter / to get suggestions")
|
47 |
+
sender.change(fn=change_sender,
|
48 |
+
inputs=[sender],
|
49 |
+
outputs=[suggestion])
|
50 |
+
suggestion.select(fn=select_suggestion,
|
51 |
+
outputs=[sender, suggestion])
|
52 |
+
|
53 |
+
if __name__ == "__main__":
|
54 |
+
demo.queue().launch()
|
components/antdx/thought_chain/README-zh_CN.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ThoughtChain
|
2 |
+
|
3 |
+
The ThoughtChain component is used to visualize and track the call chain of Actions and Tools invoked by an Agent. See [Ant Design X](https://x.ant.design/components/thought-chain/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="item_status" title="Item Status"></demo>
|
9 |
+
<demo name="nested_use" title="Nested Use"></demo>
|
components/antdx/thought_chain/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ThoughtChain
|
2 |
+
|
3 |
+
The ThoughtChain component is used to visualize and track the call chain of Actions and Tools invoked by an Agent. See [Ant Design X](https://x.ant.design/components/thought-chain/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="item_status" title="Item Status"></demo>
|
9 |
+
<demo name="nested_use" title="Nested Use"></demo>
|
components/antdx/thought_chain/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/thought_chain/demos/basic.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
default_collapsible = False
|
7 |
+
|
8 |
+
|
9 |
+
def mock_content():
|
10 |
+
with antd.Typography.Paragraph():
|
11 |
+
antd.Typography.Paragraph(
|
12 |
+
"In the process of internal desktop applications development, many different design specs and implementations would be involved, which might cause designers and developers difficulties and duplication and reduce the efficiency of development."
|
13 |
+
)
|
14 |
+
with antd.Typography.Paragraph():
|
15 |
+
ms.Text(
|
16 |
+
"After massive project practice and summaries, Ant Design, a design language for background applications, is refined by Ant UED Team, which aims to "
|
17 |
+
)
|
18 |
+
antd.Typography.Text(
|
19 |
+
"uniform the user interface specs for internal background projects, lower the unnecessary cost of design differences and implementation and liberate the resources of design and front-end development",
|
20 |
+
strong=True,
|
21 |
+
)
|
22 |
+
|
23 |
+
|
24 |
+
with gr.Blocks() as demo:
|
25 |
+
with ms.Application():
|
26 |
+
with antdx.XProvider():
|
27 |
+
collapsible = antd.Switch(default_collapsible,
|
28 |
+
checked_children="Collapsible",
|
29 |
+
un_checked_children="Not Collapsible")
|
30 |
+
with antd.Card():
|
31 |
+
with antdx.ThoughtChain(
|
32 |
+
collapsible=default_collapsible) as thought_chain:
|
33 |
+
with antdx.ThoughtChain.Item(
|
34 |
+
title="Thought Chain Item Title 1",
|
35 |
+
description="description",
|
36 |
+
status="success"):
|
37 |
+
with ms.Slot("extra"):
|
38 |
+
with antd.Button(value=None, type="text"):
|
39 |
+
with ms.Slot("icon"):
|
40 |
+
antd.Icon("MoreOutlined")
|
41 |
+
with ms.Slot("content"):
|
42 |
+
mock_content()
|
43 |
+
with ms.Slot("footer"):
|
44 |
+
antd.Button("Thought Chain Item Footer",
|
45 |
+
block=True)
|
46 |
+
with antdx.ThoughtChain.Item(
|
47 |
+
title="Thought Chain Item Title 2",
|
48 |
+
description="description",
|
49 |
+
status="error"):
|
50 |
+
with ms.Slot("extra"):
|
51 |
+
with antd.Button(value=None, type="text"):
|
52 |
+
with ms.Slot("icon"):
|
53 |
+
antd.Icon("MoreOutlined")
|
54 |
+
with ms.Slot("content"):
|
55 |
+
mock_content()
|
56 |
+
with ms.Slot("footer"):
|
57 |
+
antd.Button("Thought Chain Item Footer",
|
58 |
+
block=True)
|
59 |
+
with antdx.ThoughtChain.Item(
|
60 |
+
title="Thought Chain Item Title 3",
|
61 |
+
description="description",
|
62 |
+
status="pending"):
|
63 |
+
with ms.Slot("extra"):
|
64 |
+
with antd.Button(value=None, type="text"):
|
65 |
+
with ms.Slot("icon"):
|
66 |
+
antd.Icon("MoreOutlined")
|
67 |
+
with ms.Slot("content"):
|
68 |
+
mock_content()
|
69 |
+
with ms.Slot("footer"):
|
70 |
+
antd.Button("Thought Chain Item Footer",
|
71 |
+
block=True)
|
72 |
+
collapsible.change(fn=lambda x: gr.update(collapsible=x),
|
73 |
+
inputs=[collapsible],
|
74 |
+
outputs=[thought_chain])
|
75 |
+
if __name__ == "__main__":
|
76 |
+
demo.queue().launch()
|
components/antdx/thought_chain/demos/item_status.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
+
|
8 |
+
|
9 |
+
def run_next(each_value):
|
10 |
+
each_value.append({
|
11 |
+
"title": f'Thought Chain Item - {len(each_value) + 1}',
|
12 |
+
"status": 'pending',
|
13 |
+
"description": 'status: pending',
|
14 |
+
"icon": "LoadingOutlined",
|
15 |
+
"key": str(len(each_value) + 1)
|
16 |
+
})
|
17 |
+
yield gr.update(value="Running", loading=True), gr.update(value=each_value)
|
18 |
+
time.sleep(0.8)
|
19 |
+
each_value[-1]["status"] = "error"
|
20 |
+
each_value[-1]["description"] = 'status: error'
|
21 |
+
each_value[-1]["icon"] = "InfoCircleOutlined"
|
22 |
+
yield gr.skip(), gr.update(value=each_value)
|
23 |
+
time.sleep(0.8)
|
24 |
+
each_value[-1]["status"] = "pending"
|
25 |
+
each_value[-1]["description"] = 'status: pending'
|
26 |
+
each_value[-1]["icon"] = 'LoadingOutlined'
|
27 |
+
yield gr.skip(), gr.update(value=each_value)
|
28 |
+
time.sleep(0.8)
|
29 |
+
each_value[-1]["status"] = "success"
|
30 |
+
each_value[-1]["description"] = 'status: success'
|
31 |
+
each_value[-1]["icon"] = "CheckCircleOutlined"
|
32 |
+
yield gr.update(value="Run Next",
|
33 |
+
loading=False), gr.update(value=each_value)
|
34 |
+
|
35 |
+
|
36 |
+
with gr.Blocks() as demo:
|
37 |
+
with ms.Application():
|
38 |
+
with antdx.XProvider():
|
39 |
+
antd.Typography.Paragraph(
|
40 |
+
"The thought chain nodes support configuring the `status` property to clearly indicate the current execution status of the node."
|
41 |
+
)
|
42 |
+
with antd.Card():
|
43 |
+
with antd.Flex(vertical=True, gap="middle"):
|
44 |
+
with ms.Div():
|
45 |
+
btn = antd.Button("Run Next")
|
46 |
+
with antdx.ThoughtChain():
|
47 |
+
with ms.Each(value=[
|
48 |
+
{
|
49 |
+
"title": 'Thought Chain Item - 1',
|
50 |
+
"status": 'success',
|
51 |
+
"description": 'status: success',
|
52 |
+
"icon": 'CheckCircleOutlined',
|
53 |
+
"key": "1"
|
54 |
+
},
|
55 |
+
{
|
56 |
+
"title": 'Thought Chain Item - 2',
|
57 |
+
"status": 'error',
|
58 |
+
"description": 'status: error',
|
59 |
+
"icon": 'InfoCircleOutlined',
|
60 |
+
"key": "2"
|
61 |
+
},
|
62 |
+
]) as each:
|
63 |
+
with antdx.ThoughtChain.Item():
|
64 |
+
with ms.Slot("icon"):
|
65 |
+
antd.Icon(as_item="icon")
|
66 |
+
|
67 |
+
btn.click(fn=run_next, inputs=[each], outputs=[btn, each])
|
68 |
+
|
69 |
+
if __name__ == "__main__":
|
70 |
+
demo.queue().launch()
|
components/antdx/thought_chain/demos/nested_use.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
with antd.Card():
|
10 |
+
with antdx.ThoughtChain(collapsible=True):
|
11 |
+
with antdx.ThoughtChain.Item(
|
12 |
+
title="1 - Thought Chain Item",
|
13 |
+
description="description"):
|
14 |
+
with ms.Slot("extra"):
|
15 |
+
with antd.Button(value=None, type="text"):
|
16 |
+
with ms.Slot("icon"):
|
17 |
+
antd.Icon("MoreOutlined")
|
18 |
+
with ms.Slot("content"):
|
19 |
+
with antdx.ThoughtChain():
|
20 |
+
with antdx.ThoughtChain.Item(
|
21 |
+
title="1-1 - Thought Chain Item",
|
22 |
+
description="description"):
|
23 |
+
with ms.Slot("extra"):
|
24 |
+
with antd.Button(value=None,
|
25 |
+
type="text"):
|
26 |
+
with ms.Slot("icon"):
|
27 |
+
antd.Icon("MoreOutlined")
|
28 |
+
with antdx.ThoughtChain.Item(
|
29 |
+
title="1-2 - Thought Chain Item",
|
30 |
+
description="description"):
|
31 |
+
with ms.Slot("extra"):
|
32 |
+
with antd.Button(value=None,
|
33 |
+
type="text"):
|
34 |
+
with ms.Slot("icon"):
|
35 |
+
antd.Icon("MoreOutlined")
|
36 |
+
with ms.Slot("footer"):
|
37 |
+
antd.Button("1 - Thought Chain Item Footer")
|
38 |
+
with antdx.ThoughtChain.Item(
|
39 |
+
title="2 - Thought Chain Item",
|
40 |
+
description="description"):
|
41 |
+
with ms.Slot("extra"):
|
42 |
+
with antd.Button(value=None, type="text"):
|
43 |
+
with ms.Slot("icon"):
|
44 |
+
antd.Icon("MoreOutlined")
|
45 |
+
with ms.Slot("content"):
|
46 |
+
with antdx.ThoughtChain():
|
47 |
+
with antdx.ThoughtChain.Item(
|
48 |
+
title="2-1 - Thought Chain Item",
|
49 |
+
description="description"):
|
50 |
+
with ms.Slot("extra"):
|
51 |
+
with antd.Button(value=None,
|
52 |
+
type="text"):
|
53 |
+
with ms.Slot("icon"):
|
54 |
+
antd.Icon("MoreOutlined")
|
55 |
+
with antdx.ThoughtChain.Item(
|
56 |
+
title="2-2 - Thought Chain Item",
|
57 |
+
description="description"):
|
58 |
+
with ms.Slot("extra"):
|
59 |
+
with antd.Button(value=None,
|
60 |
+
type="text"):
|
61 |
+
with ms.Slot("icon"):
|
62 |
+
antd.Icon("MoreOutlined")
|
63 |
+
with ms.Slot("footer"):
|
64 |
+
antd.Button("2 - Thought Chain Item Footer")
|
65 |
+
|
66 |
+
if __name__ == "__main__":
|
67 |
+
demo.queue().launch()
|
components/antdx/x_provider/README-zh_CN.md
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# XProvider
|
2 |
+
|
3 |
+
Provide a uniform configuration support for x components.. See [Ant Design X](https://x.ant.design/components/x-provider/) for more information.
|
4 |
+
|
5 |
+
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
6 |
+
|
7 |
+
If you are already using `ConfigProvider` from antd, please make the following changes to your code:
|
8 |
+
|
9 |
+
```python
|
10 |
+
import modelscope_studio.components.antd as antd
|
11 |
+
import modelscope_studio.components.antdx as antdx
|
12 |
+
import modelscope_studio.components.base as ms
|
13 |
+
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
with ms.Application():
|
16 |
+
- with antd.ConfigProvider():
|
17 |
+
+ with antdx.XProvider():
|
18 |
+
```
|
components/antdx/x_provider/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# XProvider
|
2 |
+
|
3 |
+
Provide a uniform configuration support for x components.. See [Ant Design X](https://x.ant.design/components/x-provider/) for more information.
|
4 |
+
|
5 |
+
The `XProvider` extends the `ConfigProvider` from antd and provides global configuration for components in `@ant-design/x`.
|
6 |
+
|
7 |
+
If you are already using `ConfigProvider` from antd, please make the following changes to your code:
|
8 |
+
|
9 |
+
```python
|
10 |
+
import modelscope_studio.components.antd as antd
|
11 |
+
import modelscope_studio.components.antdx as antdx
|
12 |
+
import modelscope_studio.components.base as ms
|
13 |
+
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
with ms.Application():
|
16 |
+
- with antd.ConfigProvider():
|
17 |
+
+ with antdx.XProvider():
|
18 |
+
```
|
components/antdx/x_provider/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/base/application/demos/language_adaptation.py
CHANGED
@@ -12,6 +12,12 @@ messages = {
|
|
12 |
},
|
13 |
'zh-CN': {
|
14 |
"hello": "你好"
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
}
|
17 |
|
@@ -20,11 +26,11 @@ default_lang = "en"
|
|
20 |
|
21 |
def mount(e: gr.EventData, _state):
|
22 |
lang = e._data["language"]
|
23 |
-
if
|
24 |
_state["current_lang"] = lang
|
25 |
yield 'Switch Language...', _state
|
26 |
time.sleep(2)
|
27 |
-
yield messages[
|
28 |
|
29 |
|
30 |
with gr.Blocks() as demo:
|
|
|
12 |
},
|
13 |
'zh-CN': {
|
14 |
"hello": "你好"
|
15 |
+
},
|
16 |
+
"ja-JP": {
|
17 |
+
"hello": "こんにちは"
|
18 |
+
},
|
19 |
+
"ko-KR": {
|
20 |
+
"hello": "안녕하세요"
|
21 |
}
|
22 |
}
|
23 |
|
|
|
26 |
|
27 |
def mount(e: gr.EventData, _state):
|
28 |
lang = e._data["language"]
|
29 |
+
if lang in messages:
|
30 |
_state["current_lang"] = lang
|
31 |
yield 'Switch Language...', _state
|
32 |
time.sleep(2)
|
33 |
+
yield messages[_state["current_lang"]]["hello"], _state
|
34 |
|
35 |
|
36 |
with gr.Blocks() as demo:
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
modelscope_studio==1.1.
|
2 |
openai
|
|
|
1 |
+
modelscope_studio==1.1.4
|
2 |
openai
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "modelscope_studio"
|
11 |
-
version = "1.1.
|
12 |
description = "A third-party component library based on Gradio."
|
13 |
readme = "README.md"
|
14 |
license = "Apache-2.0"
|
|
|
8 |
|
9 |
[project]
|
10 |
name = "modelscope_studio"
|
11 |
+
version = "1.1.4"
|
12 |
description = "A third-party component library based on Gradio."
|
13 |
readme = "README.md"
|
14 |
license = "Apache-2.0"
|