Spaces:
Running
Running
docs: update legacy demo
Browse files- components/legacy/Chatbot/demos/accordion.py +2 -1
- components/legacy/Chatbot/demos/basic.py +2 -1
- components/legacy/Chatbot/demos/chart.py +2 -1
- components/legacy/Chatbot/demos/message_config.py +2 -1
- components/legacy/Chatbot/demos/multi_bots.py +2 -1
- components/legacy/Chatbot/demos/multimodal.py +2 -1
- components/legacy/Chatbot/demos/select-box.py +2 -1
- components/legacy/Flow/demos/basic.py +2 -1
- components/legacy/Flow/demos/component_options.py +2 -1
- components/legacy/Flow/demos/custom_node_type.py +2 -1
- components/legacy/Lifecycle/demos/basic.py +2 -1
- components/legacy/Lifecycle/demos/language_adaptation.py +2 -1
- components/legacy/Lifecycle/demos/theme_adaptation.py +2 -1
- components/legacy/Markdown/demos/accordion.py +2 -1
- components/legacy/Markdown/demos/basic.py +2 -1
- components/legacy/Markdown/demos/chart.py +2 -1
- components/legacy/Markdown/demos/custom-tag.py +2 -1
- components/legacy/Markdown/demos/custom-tag2.py +2 -1
- components/legacy/Markdown/demos/custom-tag3.py +2 -1
- components/legacy/Markdown/demos/custom-tag4.py +2 -1
- components/legacy/Markdown/demos/custom_tags/accordion/accordion-title.py +2 -1
- components/legacy/Markdown/demos/custom_tags/accordion/basic.py +2 -1
- components/legacy/Markdown/demos/custom_tags/chart/basic.py +2 -1
- components/legacy/Markdown/demos/custom_tags/select-box/basic.py +2 -1
- components/legacy/Markdown/demos/custom_tags/select-box/card_shape.py +2 -1
- components/legacy/Markdown/demos/custom_tags/select-box/card_shape_width_auto.py +2 -1
- components/legacy/Markdown/demos/custom_tags/select-box/python_events.py +2 -1
- components/legacy/Markdown/demos/multimodal.py +2 -1
- components/legacy/Markdown/demos/select-box.py +2 -1
- components/legacy/MultimodalInput/demos/basic.py +2 -1
- components/legacy/MultimodalInput/demos/config_buttons.py +2 -1
- components/legacy/MultimodalInput/demos/upload_sources.py +2 -1
- components/legacy/MultimodalInput/demos/with_chatbot.py +2 -1
- components/legacy/WaterfallGallery/demos/basic.py +2 -1
- components/legacy/WaterfallGallery/demos/like_click_feedback.py +2 -1
- components/legacy/WaterfallGallery/demos/load_more.py +2 -1
- components/legacy/WaterfallGallery/demos/responsive_columns.py +2 -1
- requirements.txt +1 -1
- src/pyproject.toml +1 -1
components/legacy/Chatbot/demos/accordion.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
from modelscope_studio.components.legacy.Chatbot.llm_thinking_presets import \
|
7 |
qwen
|
8 |
|
@@ -40,7 +41,7 @@ Observation: <result>「Any md content will be displayed in the drop-down box wh
|
|
40 |
],
|
41 |
]
|
42 |
|
43 |
-
with gr.Blocks() as demo:
|
44 |
mgr.Chatbot(
|
45 |
value=conversation,
|
46 |
llm_thinking_presets=[qwen()],
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
from modelscope_studio.components.legacy.Chatbot.llm_thinking_presets import \
|
8 |
qwen
|
9 |
|
|
|
41 |
],
|
42 |
]
|
43 |
|
44 |
+
with gr.Blocks() as demo, ms.Application():
|
45 |
mgr.Chatbot(
|
46 |
value=conversation,
|
47 |
llm_thinking_presets=[qwen()],
|
components/legacy/Chatbot/demos/basic.py
CHANGED
@@ -4,6 +4,7 @@ import time
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
conversation = [
|
9 |
[
|
@@ -31,7 +32,7 @@ def flushed():
|
|
31 |
return gr.update(interactive=True)
|
32 |
|
33 |
|
34 |
-
with gr.Blocks() as demo:
|
35 |
chatbot = mgr.Chatbot(
|
36 |
value=conversation,
|
37 |
avatar_images=[
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
conversation = [
|
10 |
[
|
|
|
32 |
return gr.update(interactive=True)
|
33 |
|
34 |
|
35 |
+
with gr.Blocks() as demo, ms.Application():
|
36 |
chatbot = mgr.Chatbot(
|
37 |
value=conversation,
|
38 |
avatar_images=[
|
components/legacy/Chatbot/demos/chart.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
8 |
option1 = {
|
@@ -32,7 +33,7 @@ Chart:
|
|
32 |
],
|
33 |
]
|
34 |
|
35 |
-
with gr.Blocks() as demo:
|
36 |
mgr.Chatbot(
|
37 |
value=conversation,
|
38 |
flushing=False,
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
9 |
option1 = {
|
|
|
33 |
],
|
34 |
]
|
35 |
|
36 |
+
with gr.Blocks() as demo, ms.Application():
|
37 |
mgr.Chatbot(
|
38 |
value=conversation,
|
39 |
flushing=False,
|
components/legacy/Chatbot/demos/message_config.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def submit(_chatbot):
|
@@ -26,7 +27,7 @@ def submit(_chatbot):
|
|
26 |
yield _chatbot
|
27 |
|
28 |
|
29 |
-
with gr.Blocks() as demo:
|
30 |
chatbot = mgr.Chatbot(height=600, )
|
31 |
button = gr.Button("Submit")
|
32 |
button.click(fn=submit, inputs=[chatbot], outputs=[chatbot])
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def submit(_chatbot):
|
|
|
27 |
yield _chatbot
|
28 |
|
29 |
|
30 |
+
with gr.Blocks() as demo, ms.Application():
|
31 |
chatbot = mgr.Chatbot(height=600, )
|
32 |
button = gr.Button("Submit")
|
33 |
button.click(fn=submit, inputs=[chatbot], outputs=[chatbot])
|
components/legacy/Chatbot/demos/multi_bots.py
CHANGED
@@ -4,6 +4,7 @@ import time
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
@@ -58,7 +59,7 @@ def flushed():
|
|
58 |
return gr.update(interactive=True)
|
59 |
|
60 |
|
61 |
-
with gr.Blocks() as demo:
|
62 |
chatbot = mgr.Chatbot(
|
63 |
value=conversation,
|
64 |
avatar_image_width=40,
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
|
10 |
def resolve_assets(relative_path):
|
|
|
59 |
return gr.update(interactive=True)
|
60 |
|
61 |
|
62 |
+
with gr.Blocks() as demo, ms.Application():
|
63 |
chatbot = mgr.Chatbot(
|
64 |
value=conversation,
|
65 |
avatar_image_width=40,
|
components/legacy/Chatbot/demos/multimodal.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def resolve_assets(relative_path):
|
@@ -29,7 +30,7 @@ Audio
|
|
29 |
],
|
30 |
]
|
31 |
|
32 |
-
with gr.Blocks() as demo:
|
33 |
mgr.Chatbot(
|
34 |
value=conversation,
|
35 |
height=600,
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
|
|
30 |
],
|
31 |
]
|
32 |
|
33 |
+
with gr.Blocks() as demo, ms.Application():
|
34 |
mgr.Chatbot(
|
35 |
value=conversation,
|
36 |
height=600,
|
components/legacy/Chatbot/demos/select-box.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
# `label` will display on the page, and `value` is the actual selected value.
|
8 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
@@ -35,7 +36,7 @@ def fn(data: gr.EventData):
|
|
35 |
print(data._data)
|
36 |
|
37 |
|
38 |
-
with gr.Blocks() as demo:
|
39 |
chatbot = mgr.Chatbot(
|
40 |
value=conversation,
|
41 |
flushing=False,
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
# `label` will display on the page, and `value` is the actual selected value.
|
9 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
|
|
36 |
print(data._data)
|
37 |
|
38 |
|
39 |
+
with gr.Blocks() as demo, ms.Application():
|
40 |
chatbot = mgr.Chatbot(
|
41 |
value=conversation,
|
42 |
flushing=False,
|
components/legacy/Flow/demos/basic.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
from modelscope_studio.components.legacy.Flow import Edge, Node
|
8 |
|
9 |
with open((os.path.join(os.path.dirname(__file__),
|
@@ -27,7 +28,7 @@ def on_data_change(_flow):
|
|
27 |
print(_flow)
|
28 |
|
29 |
|
30 |
-
with gr.Blocks() as demo:
|
31 |
flow = mgr.Flow(value=data, schema=schema, sync_on_data_change=True)
|
32 |
flow.data_change(fn=on_data_change, inputs=[flow])
|
33 |
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
from modelscope_studio.components.legacy.Flow import Edge, Node
|
9 |
|
10 |
with open((os.path.join(os.path.dirname(__file__),
|
|
|
28 |
print(_flow)
|
29 |
|
30 |
|
31 |
+
with gr.Blocks() as demo, ms.Application():
|
32 |
flow = mgr.Flow(value=data, schema=schema, sync_on_data_change=True)
|
33 |
flow.data_change(fn=on_data_change, inputs=[flow])
|
34 |
|
components/legacy/Flow/demos/component_options.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
from modelscope_studio.components.legacy.Flow import (BackgroundPropsDict,
|
8 |
Edge, Node)
|
9 |
|
@@ -51,7 +52,7 @@ def on_change(_flow_config, _bgc_variant, _bgc_color, _bgc_bg_color, _bgc_gap,
|
|
51 |
return gr.update(**new_props, background_props=new_background_props)
|
52 |
|
53 |
|
54 |
-
with gr.Blocks() as demo:
|
55 |
with gr.Accordion(label="Flow Options"):
|
56 |
flow_config = gr.CheckboxGroup(
|
57 |
container=False,
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
from modelscope_studio.components.legacy.Flow import (BackgroundPropsDict,
|
9 |
Edge, Node)
|
10 |
|
|
|
52 |
return gr.update(**new_props, background_props=new_background_props)
|
53 |
|
54 |
|
55 |
+
with gr.Blocks() as demo, ms.Application():
|
56 |
with gr.Accordion(label="Flow Options"):
|
57 |
flow_config = gr.CheckboxGroup(
|
58 |
container=False,
|
components/legacy/Flow/demos/custom_node_type.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
from modelscope_studio.components.legacy.Flow import (FlowSchemaDict, Node,
|
5 |
NodeSchemaAttributeDict,
|
6 |
NodeSchemaDict)
|
@@ -56,7 +57,7 @@ data = {
|
|
56 |
]
|
57 |
}
|
58 |
|
59 |
-
with gr.Blocks() as demo:
|
60 |
flow = mgr.Flow(value=data,
|
61 |
schema=schema,
|
62 |
custom_components=custom_components,
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
from modelscope_studio.components.legacy.Flow import (FlowSchemaDict, Node,
|
6 |
NodeSchemaAttributeDict,
|
7 |
NodeSchemaDict)
|
|
|
57 |
]
|
58 |
}
|
59 |
|
60 |
+
with gr.Blocks() as demo, ms.Application():
|
61 |
flow = mgr.Flow(value=data,
|
62 |
schema=schema,
|
63 |
custom_components=custom_components,
|
components/legacy/Lifecycle/demos/basic.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
|
6 |
def mount(e: gr.EventData):
|
@@ -16,7 +17,7 @@ def onUnmount(e: gr.EventData):
|
|
16 |
print("onUnmount", e._data)
|
17 |
|
18 |
|
19 |
-
with gr.Blocks() as demo:
|
20 |
gr.Markdown("The Lifecycle component will not be rendered on the page.")
|
21 |
lifecycle = mgr.Lifecycle()
|
22 |
# listen to the page lifecycle
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
|
7 |
def mount(e: gr.EventData):
|
|
|
17 |
print("onUnmount", e._data)
|
18 |
|
19 |
|
20 |
+
with gr.Blocks() as demo, ms.Application():
|
21 |
gr.Markdown("The Lifecycle component will not be rendered on the page.")
|
22 |
lifecycle = mgr.Lifecycle()
|
23 |
# listen to the page lifecycle
|
components/legacy/Lifecycle/demos/language_adaptation.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
messages = {
|
8 |
'en': {
|
@@ -28,7 +29,7 @@ def mount(_lifecycle, _state):
|
|
28 |
yield messages[lang]["hello"], _state
|
29 |
|
30 |
|
31 |
-
with gr.Blocks() as demo:
|
32 |
lifecycle = mgr.Lifecycle()
|
33 |
state = gr.State({"current_lang": default_lang})
|
34 |
markdown = gr.Markdown(value=messages[default_lang]["hello"])
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
messages = {
|
9 |
'en': {
|
|
|
29 |
yield messages[lang]["hello"], _state
|
30 |
|
31 |
|
32 |
+
with gr.Blocks() as demo, ms.Application():
|
33 |
lifecycle = mgr.Lifecycle()
|
34 |
state = gr.State({"current_lang": default_lang})
|
35 |
markdown = gr.Markdown(value=messages[default_lang]["hello"])
|
components/legacy/Lifecycle/demos/theme_adaptation.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
|
6 |
def mount(_lifecycle, _state):
|
@@ -15,7 +16,7 @@ def fn(_state):
|
|
15 |
value=f"https://dummyimage.com/200x100/{color}.png&text={theme}")
|
16 |
|
17 |
|
18 |
-
with gr.Blocks() as demo:
|
19 |
lifecycle = mgr.Lifecycle()
|
20 |
state = gr.State({"theme": "light"})
|
21 |
btn = gr.Button()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
|
7 |
def mount(_lifecycle, _state):
|
|
|
16 |
value=f"https://dummyimage.com/200x100/{color}.png&text={theme}")
|
17 |
|
18 |
|
19 |
+
with gr.Blocks() as demo, ms.Application():
|
20 |
lifecycle = mgr.Lifecycle()
|
21 |
state = gr.State({"theme": "light"})
|
22 |
btn = gr.Button()
|
components/legacy/Markdown/demos/accordion.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown("""
|
7 |
<accordion title="Using tool">
|
8 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown("""
|
8 |
<accordion title="Using tool">
|
9 |
|
components/legacy/Markdown/demos/basic.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown(
|
7 |
"This _example_ was **written** in [Markdown](https://en.wikipedia.org/wiki/Markdown)\n"
|
8 |
)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown(
|
8 |
"This _example_ was **written** in [Markdown](https://en.wikipedia.org/wiki/Markdown)\n"
|
9 |
)
|
components/legacy/Markdown/demos/chart.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
8 |
option1 = {
|
@@ -21,7 +22,7 @@ option1 = {
|
|
21 |
],
|
22 |
}
|
23 |
|
24 |
-
with gr.Blocks() as demo:
|
25 |
mgr.Markdown(f"""
|
26 |
Chart:
|
27 |
<chart options='{json.dumps(option1)}'></chart>
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
9 |
option1 = {
|
|
|
22 |
],
|
23 |
}
|
24 |
|
25 |
+
with gr.Blocks() as demo, ms.Application():
|
26 |
mgr.Markdown(f"""
|
27 |
Chart:
|
28 |
<chart options='{json.dumps(option1)}'></chart>
|
components/legacy/Markdown/demos/custom-tag.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown(
|
7 |
"""
|
8 |
custom tag:<custom-tag value="aaa"></custom-tag>
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown(
|
8 |
"""
|
9 |
custom tag:<custom-tag value="aaa"></custom-tag>
|
components/legacy/Markdown/demos/custom-tag2.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown(
|
7 |
"""
|
8 |
custom tag:<custom-tag value="aaa"></custom-tag>
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown(
|
8 |
"""
|
9 |
custom tag:<custom-tag value="aaa"></custom-tag>
|
components/legacy/Markdown/demos/custom-tag3.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
options = ["a", "b", "c"]
|
9 |
|
@@ -16,7 +17,7 @@ def resolve_assets(relative_path):
|
|
16 |
with open(resolve_assets("./custom_components/custom_select.js"), 'r') as f:
|
17 |
custom_select_js = f.read()
|
18 |
|
19 |
-
with gr.Blocks() as demo:
|
20 |
mgr.Markdown(value=f"""
|
21 |
custom tag: <custom-select options='{json.dumps(options)}'></custom-select>
|
22 |
""",
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
options = ["a", "b", "c"]
|
10 |
|
|
|
17 |
with open(resolve_assets("./custom_components/custom_select.js"), 'r') as f:
|
18 |
custom_select_js = f.read()
|
19 |
|
20 |
+
with gr.Blocks() as demo, ms.Application():
|
21 |
mgr.Markdown(value=f"""
|
22 |
custom tag: <custom-select options='{json.dumps(options)}'></custom-select>
|
23 |
""",
|
components/legacy/Markdown/demos/custom-tag4.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
options = ["a", "b", "c"]
|
9 |
|
@@ -22,7 +23,7 @@ def fn(data: gr.EventData):
|
|
22 |
print("custom value", data._data)
|
23 |
|
24 |
|
25 |
-
with gr.Blocks() as demo:
|
26 |
md = mgr.Markdown(value=f"""
|
27 |
custom tag: <custom-select options='{json.dumps(options)}'></custom-select>
|
28 |
""",
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
options = ["a", "b", "c"]
|
10 |
|
|
|
23 |
print("custom value", data._data)
|
24 |
|
25 |
|
26 |
+
with gr.Blocks() as demo, ms.Application():
|
27 |
md = mgr.Markdown(value=f"""
|
28 |
custom tag: <custom-select options='{json.dumps(options)}'></custom-select>
|
29 |
""",
|
components/legacy/Markdown/demos/custom_tags/accordion/accordion-title.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown("""
|
7 |
<accordion>
|
8 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown("""
|
8 |
<accordion>
|
9 |
|
components/legacy/Markdown/demos/custom_tags/accordion/basic.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
-
with gr.Blocks() as demo:
|
6 |
mgr.Markdown("""
|
7 |
<accordion title="Using tool">
|
8 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
+
with gr.Blocks() as demo, ms.Application():
|
7 |
mgr.Markdown("""
|
8 |
<accordion title="Using tool">
|
9 |
|
components/legacy/Markdown/demos/custom_tags/chart/basic.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
8 |
option1 = {
|
@@ -75,7 +76,7 @@ option2 = {
|
|
75 |
}]
|
76 |
}
|
77 |
|
78 |
-
with gr.Blocks() as demo:
|
79 |
chatbot = mgr.Markdown(f"""<chart options='{json.dumps(option1)}'></chart>
|
80 |
|
81 |
<chart options='{json.dumps(option2)}'></chart>
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
# echarts options, see: https://echarts.apache.org/en/index.html
|
9 |
option1 = {
|
|
|
76 |
}]
|
77 |
}
|
78 |
|
79 |
+
with gr.Blocks() as demo, ms.Application():
|
80 |
chatbot = mgr.Markdown(f"""<chart options='{json.dumps(option1)}'></chart>
|
81 |
|
82 |
<chart options='{json.dumps(option2)}'></chart>
|
components/legacy/Markdown/demos/custom_tags/select-box/basic.py
CHANGED
@@ -3,10 +3,11 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
8 |
|
9 |
-
with gr.Blocks() as demo:
|
10 |
mgr.Markdown(
|
11 |
f"""Single Select: <select-box options='{json.dumps(options)}' select-once></select-box>
|
12 |
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
9 |
|
10 |
+
with gr.Blocks() as demo, ms.Application():
|
11 |
mgr.Markdown(
|
12 |
f"""Single Select: <select-box options='{json.dumps(options)}' select-once></select-box>
|
13 |
|
components/legacy/Markdown/demos/custom_tags/select-box/card_shape.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
# Card shape supports setting `imgSrc` as the cover.
|
9 |
options = [{
|
@@ -16,7 +17,7 @@ options = [{
|
|
16 |
"a"
|
17 |
}, "b", "c", "d"]
|
18 |
|
19 |
-
with gr.Blocks() as demo:
|
20 |
mgr.Markdown(
|
21 |
f"""<select-box shape="card" options='{json.dumps(options)}' select-once equal-height></select-box>
|
22 |
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
# Card shape supports setting `imgSrc` as the cover.
|
10 |
options = [{
|
|
|
17 |
"a"
|
18 |
}, "b", "c", "d"]
|
19 |
|
20 |
+
with gr.Blocks() as demo, ms.Application():
|
21 |
mgr.Markdown(
|
22 |
f"""<select-box shape="card" options='{json.dumps(options)}' select-once equal-height></select-box>
|
23 |
|
components/legacy/Markdown/demos/custom_tags/select-box/card_shape_width_auto.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
# Card shape supports setting `imgSrc` as the cover.
|
9 |
options = [{
|
@@ -16,7 +17,7 @@ options = [{
|
|
16 |
"a"
|
17 |
}, "b", "c", "d"]
|
18 |
|
19 |
-
with gr.Blocks() as demo:
|
20 |
mgr.Markdown(
|
21 |
# item-width="auto"
|
22 |
f"""
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
# Card shape supports setting `imgSrc` as the cover.
|
10 |
options = [{
|
|
|
17 |
"a"
|
18 |
}, "b", "c", "d"]
|
19 |
|
20 |
+
with gr.Blocks() as demo, ms.Application():
|
21 |
mgr.Markdown(
|
22 |
# item-width="auto"
|
23 |
f"""
|
components/legacy/Markdown/demos/custom_tags/select-box/python_events.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
8 |
|
@@ -14,7 +15,7 @@ def fn(data: gr.EventData):
|
|
14 |
) # 'a' or 'b' or 'c', the value set in the options.
|
15 |
|
16 |
|
17 |
-
with gr.Blocks() as demo:
|
18 |
md = mgr.Markdown(
|
19 |
f"<select-box options='{json.dumps(options)}' select-once></select-box>"
|
20 |
)
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
9 |
|
|
|
15 |
) # 'a' or 'b' or 'c', the value set in the options.
|
16 |
|
17 |
|
18 |
+
with gr.Blocks() as demo, ms.Application():
|
19 |
md = mgr.Markdown(
|
20 |
f"<select-box options='{json.dumps(options)}' select-once></select-box>"
|
21 |
)
|
components/legacy/Markdown/demos/multimodal.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def resolve_assets(relative_path):
|
@@ -10,7 +11,7 @@ def resolve_assets(relative_path):
|
|
10 |
relative_path)
|
11 |
|
12 |
|
13 |
-
with gr.Blocks() as demo:
|
14 |
mgr.Markdown(f"""
|
15 |
Image
|
16 |
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
|
|
11 |
relative_path)
|
12 |
|
13 |
|
14 |
+
with gr.Blocks() as demo, ms.Application():
|
15 |
mgr.Markdown(f"""
|
16 |
Image
|
17 |
|
components/legacy/Markdown/demos/select-box.py
CHANGED
@@ -3,11 +3,12 @@ import json
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
# `label` will display on the page, and `value` is the actual selected value.
|
8 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
9 |
|
10 |
-
with gr.Blocks() as demo:
|
11 |
mgr.Markdown(f"""
|
12 |
Single Select: <select-box options='{json.dumps(options)}' select-once></select-box>
|
13 |
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
# `label` will display on the page, and `value` is the actual selected value.
|
9 |
options = [{"label": "A", "value": "a"}, "b", "c"]
|
10 |
|
11 |
+
with gr.Blocks() as demo, ms.Application():
|
12 |
mgr.Markdown(f"""
|
13 |
Single Select: <select-box options='{json.dumps(options)}' select-once></select-box>
|
14 |
|
components/legacy/MultimodalInput/demos/basic.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
|
6 |
def fn(value):
|
@@ -8,7 +9,7 @@ def fn(value):
|
|
8 |
print(value.text, value.files)
|
9 |
|
10 |
|
11 |
-
with gr.Blocks() as demo:
|
12 |
input = mgr.MultimodalInput()
|
13 |
input.change(fn=fn, inputs=[input])
|
14 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
|
7 |
def fn(value):
|
|
|
9 |
print(value.text, value.files)
|
10 |
|
11 |
|
12 |
+
with gr.Blocks() as demo, ms.Application():
|
13 |
input = mgr.MultimodalInput()
|
14 |
input.change(fn=fn, inputs=[input])
|
15 |
|
components/legacy/MultimodalInput/demos/config_buttons.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
|
6 |
def fn(value):
|
7 |
print(value.text, value.files)
|
8 |
|
9 |
|
10 |
-
with gr.Blocks() as demo:
|
11 |
input = mgr.MultimodalInput(upload_button_props=dict(variant="primary"),
|
12 |
submit_button_props=dict(visible=False))
|
13 |
input.change(fn=fn, inputs=[input])
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
|
7 |
def fn(value):
|
8 |
print(value.text, value.files)
|
9 |
|
10 |
|
11 |
+
with gr.Blocks() as demo, ms.Application():
|
12 |
input = mgr.MultimodalInput(upload_button_props=dict(variant="primary"),
|
13 |
submit_button_props=dict(visible=False))
|
14 |
input.change(fn=fn, inputs=[input])
|
components/legacy/MultimodalInput/demos/upload_sources.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
|
|
4 |
|
5 |
|
6 |
def fn(value):
|
7 |
print(value.text, value.files)
|
8 |
|
9 |
|
10 |
-
with gr.Blocks() as demo:
|
11 |
input = mgr.MultimodalInput(sources=["upload", "microphone", "webcam"])
|
12 |
input.change(fn=fn, inputs=[input])
|
13 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import modelscope_studio as mgr
|
4 |
+
import modelscope_studio.components.base as ms
|
5 |
|
6 |
|
7 |
def fn(value):
|
8 |
print(value.text, value.files)
|
9 |
|
10 |
|
11 |
+
with gr.Blocks() as demo, ms.Application():
|
12 |
input = mgr.MultimodalInput(sources=["upload", "microphone", "webcam"])
|
13 |
input.change(fn=fn, inputs=[input])
|
14 |
|
components/legacy/MultimodalInput/demos/with_chatbot.py
CHANGED
@@ -3,6 +3,7 @@ import time
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def fn(input, chatbot):
|
@@ -24,7 +25,7 @@ def flushed():
|
|
24 |
return mgr.MultimodalInput(interactive=True)
|
25 |
|
26 |
|
27 |
-
with gr.Blocks() as demo:
|
28 |
user_chatbot = mgr.Chatbot()
|
29 |
user_input = mgr.MultimodalInput()
|
30 |
user_input.submit(fn=fn,
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def fn(input, chatbot):
|
|
|
25 |
return mgr.MultimodalInput(interactive=True)
|
26 |
|
27 |
|
28 |
+
with gr.Blocks() as demo, ms.Application():
|
29 |
user_chatbot = mgr.Chatbot()
|
30 |
user_input = mgr.MultimodalInput()
|
31 |
user_input.submit(fn=fn,
|
components/legacy/WaterfallGallery/demos/basic.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def resolve_assets(relative_path):
|
@@ -10,7 +11,7 @@ def resolve_assets(relative_path):
|
|
10 |
relative_path)
|
11 |
|
12 |
|
13 |
-
with gr.Blocks() as demo:
|
14 |
mgr.WaterfallGallery(
|
15 |
value=[
|
16 |
resolve_assets('modelscope.svg'),
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
|
|
11 |
relative_path)
|
12 |
|
13 |
|
14 |
+
with gr.Blocks() as demo, ms.Application():
|
15 |
mgr.WaterfallGallery(
|
16 |
value=[
|
17 |
resolve_assets('modelscope.svg'),
|
components/legacy/WaterfallGallery/demos/like_click_feedback.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def resolve_assets(relative_path):
|
@@ -14,7 +15,7 @@ def fn(data: gr.EventData):
|
|
14 |
print(data._data)
|
15 |
|
16 |
|
17 |
-
with gr.Blocks() as demo:
|
18 |
gallery = mgr.WaterfallGallery(
|
19 |
value=[
|
20 |
resolve_assets('modelscope.svg'),
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
|
|
15 |
print(data._data)
|
16 |
|
17 |
|
18 |
+
with gr.Blocks() as demo, ms.Application():
|
19 |
gallery = mgr.WaterfallGallery(
|
20 |
value=[
|
21 |
resolve_assets('modelscope.svg'),
|
components/legacy/WaterfallGallery/demos/load_more.py
CHANGED
@@ -4,6 +4,7 @@ import time
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
|
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
@@ -23,7 +24,7 @@ def load_more(_gallery):
|
|
23 |
return gr.update(value=_gallery, has_more=has_more)
|
24 |
|
25 |
|
26 |
-
with gr.Blocks() as demo:
|
27 |
gallery = mgr.WaterfallGallery(
|
28 |
value=[
|
29 |
resolve_assets('modelscope.svg'),
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
import modelscope_studio as mgr
|
7 |
+
import modelscope_studio.components.base as ms
|
8 |
|
9 |
|
10 |
def resolve_assets(relative_path):
|
|
|
24 |
return gr.update(value=_gallery, has_more=has_more)
|
25 |
|
26 |
|
27 |
+
with gr.Blocks() as demo, ms.Application():
|
28 |
gallery = mgr.WaterfallGallery(
|
29 |
value=[
|
30 |
resolve_assets('modelscope.svg'),
|
components/legacy/WaterfallGallery/demos/responsive_columns.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
|
|
6 |
|
7 |
|
8 |
def resolve_assets(relative_path):
|
@@ -14,7 +15,7 @@ def fn():
|
|
14 |
return gr.update(columns={"xs": 2, "lg": 3})
|
15 |
|
16 |
|
17 |
-
with gr.Blocks() as demo:
|
18 |
gallery = mgr.WaterfallGallery(
|
19 |
value=[
|
20 |
resolve_assets('modelscope.svg'),
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
import modelscope_studio as mgr
|
6 |
+
import modelscope_studio.components.base as ms
|
7 |
|
8 |
|
9 |
def resolve_assets(relative_path):
|
|
|
15 |
return gr.update(columns={"xs": 2, "lg": 3})
|
16 |
|
17 |
|
18 |
+
with gr.Blocks() as demo, ms.Application():
|
19 |
gallery = mgr.WaterfallGallery(
|
20 |
value=[
|
21 |
resolve_assets('modelscope.svg'),
|
requirements.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
modelscope_studio==1.0.
|
|
|
1 |
+
modelscope_studio==1.0.1
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "modelscope_studio"
|
11 |
-
version = "1.0.
|
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.0.1"
|
12 |
description = "A third-party component library based on Gradio."
|
13 |
readme = "README.md"
|
14 |
license = "Apache-2.0"
|