Spaces:
Running
Running
Update
Browse files
FAQ-zh_CN.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
在 Hugging Face Space 中,默认开启了 Gradio 的 ssr 模式,但是此功能目前还无法很好的兼容自定义组件,需要我们手动关闭。请在`demo.launch()`方法中添加`ssr_mode=False`参数:`demo.launch(ssr_mode=False)`。
|
6 |
|
7 |
-
##
|
8 |
|
9 |
`modelscope_studio`将组件的加载反馈进行了单独抽离。由于 Gradio 的交互操作涉及到前后端通信,需要有一段加载中的等待时间,当没有`AutoLoading`组件时,页面将不会显示 Gradio 的加载状态。因此,建议您至少在全局使用一次`AutoLoading`组件,以显示兜底的加载反馈。
|
10 |
|
|
|
4 |
|
5 |
在 Hugging Face Space 中,默认开启了 Gradio 的 ssr 模式,但是此功能目前还无法很好的兼容自定义组件,需要我们手动关闭。请在`demo.launch()`方法中添加`ssr_mode=False`参数:`demo.launch(ssr_mode=False)`。
|
6 |
|
7 |
+
## 为什么我的应用每次操作都需要等待一小段时间才会有响应?
|
8 |
|
9 |
`modelscope_studio`将组件的加载反馈进行了单独抽离。由于 Gradio 的交互操作涉及到前后端通信,需要有一段加载中的等待时间,当没有`AutoLoading`组件时,页面将不会显示 Gradio 的加载状态。因此,建议您至少在全局使用一次`AutoLoading`组件,以显示兜底的加载反馈。
|
10 |
|
components/antd/pagination/README-zh_CN.md
CHANGED
@@ -5,3 +5,9 @@ A long list can be divided into several pages, and only one page will be loaded
|
|
5 |
## Examples
|
6 |
|
7 |
<demo name="basic"></demo>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
## Examples
|
6 |
|
7 |
<demo name="basic"></demo>
|
8 |
+
|
9 |
+
### Data Changes
|
10 |
+
|
11 |
+
The `Pagination` component is not designed as a data component and cannot be placed in the inputs of other events, but you can get the changed value of the pagination through the pagination change event. If you need to persist the page data, you can save it to `gr.State`
|
12 |
+
|
13 |
+
<demo name="data_changes">
|
components/antd/pagination/README.md
CHANGED
@@ -5,3 +5,9 @@ A long list can be divided into several pages, and only one page will be loaded
|
|
5 |
## Examples
|
6 |
|
7 |
<demo name="basic"></demo>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
## Examples
|
6 |
|
7 |
<demo name="basic"></demo>
|
8 |
+
|
9 |
+
### Data Changes
|
10 |
+
|
11 |
+
The `Pagination` component is not designed as a data component and cannot be placed in the inputs of other events, but you can get the changed value of the pagination through the pagination change event. If you need to persist the page data, you can save it to `gr.State`
|
12 |
+
|
13 |
+
<demo name="data_changes">
|
components/antd/pagination/demos/data_changes.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import modelscope_studio.components.antd as antd
|
3 |
+
import modelscope_studio.components.base as ms
|
4 |
+
|
5 |
+
|
6 |
+
def on_change(e: gr.EventData, state_value):
|
7 |
+
page = e._data["payload"][0]
|
8 |
+
page_size = e._data["payload"][1]
|
9 |
+
state_value["page"] = page
|
10 |
+
state_value["page_size"] = page_size
|
11 |
+
return state_value
|
12 |
+
|
13 |
+
|
14 |
+
def on_click(state_value):
|
15 |
+
gr.Info(
|
16 |
+
f"Page: {state_value['page']}, Page Size: {state_value['page_size']}")
|
17 |
+
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
state = gr.State({"page": 1, "page_size": 10})
|
21 |
+
with ms.Application():
|
22 |
+
with antd.ConfigProvider():
|
23 |
+
with antd.Flex(vertical=True, gap="middle"):
|
24 |
+
pagination = antd.Pagination(
|
25 |
+
total=85,
|
26 |
+
show_quick_jumper=True,
|
27 |
+
show_size_changer=True,
|
28 |
+
)
|
29 |
+
btn = antd.Button("Show me the page",
|
30 |
+
type="primary",
|
31 |
+
block=True)
|
32 |
+
pagination.change(fn=on_change, inputs=[state], outputs=[state])
|
33 |
+
btn.click(fn=on_click, inputs=[state], outputs=[btn])
|
34 |
+
if __name__ == "__main__":
|
35 |
+
demo.queue().launch()
|
layout_templates/coder_artifacts/demos/app.py
CHANGED
@@ -177,21 +177,27 @@ css = """
|
|
177 |
min-height: 680px;
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
180 |
#coder-artifacts .output-html {
|
181 |
display: flex;
|
182 |
flex-direction: column;
|
183 |
width: 100%;
|
|
|
184 |
min-height: 680px;
|
|
|
185 |
}
|
186 |
|
187 |
-
#coder-artifacts .output-html
|
188 |
-
|
189 |
}
|
190 |
|
191 |
-
#
|
192 |
flex:1;
|
193 |
}
|
194 |
-
#
|
195 |
min-height: 100%;
|
196 |
}
|
197 |
"""
|
@@ -277,10 +283,13 @@ with gr.Blocks(css=css) as demo:
|
|
277 |
|
278 |
# Right Column
|
279 |
with antd.Col(span=24, md=16):
|
280 |
-
with antd.Card(
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
284 |
# Output Container Extra
|
285 |
with ms.Slot("extra"):
|
286 |
with ms.Div(elem_id="output-container-extra"):
|
@@ -298,6 +307,7 @@ with gr.Blocks(css=css) as demo:
|
|
298 |
"🧑💻 View Code", type="primary")
|
299 |
# Output Content
|
300 |
with antd.Tabs(
|
|
|
301 |
active_key="empty",
|
302 |
render_tab_bar="() => null") as state_tab:
|
303 |
with antd.Tabs.Item(key="empty"):
|
@@ -333,7 +343,7 @@ with gr.Blocks(css=css) as demo:
|
|
333 |
placement="right",
|
334 |
get_container=
|
335 |
"() => document.querySelector('.gradio-container')",
|
336 |
-
elem_id="
|
337 |
styles=dict(
|
338 |
body=dict(display="flex",
|
339 |
flexDirection="column-reverse")),
|
|
|
177 |
min-height: 680px;
|
178 |
}
|
179 |
|
180 |
+
#coder-artifacts #output-container .ms-gr-ant-tabs-content,.ms-gr-ant-tabs-tabpane {
|
181 |
+
height: 100%;
|
182 |
+
}
|
183 |
+
|
184 |
#coder-artifacts .output-html {
|
185 |
display: flex;
|
186 |
flex-direction: column;
|
187 |
width: 100%;
|
188 |
+
height: 100%;
|
189 |
min-height: 680px;
|
190 |
+
max-height: 1200px;
|
191 |
}
|
192 |
|
193 |
+
#coder-artifacts .output-html .html-container {
|
194 |
+
height: 100%;
|
195 |
}
|
196 |
|
197 |
+
#coder-artifacts-code-drawer .output-code {
|
198 |
flex:1;
|
199 |
}
|
200 |
+
#coder-artifacts-code-drawer .output-code .ms-gr-ant-spin-nested-loading {
|
201 |
min-height: 100%;
|
202 |
}
|
203 |
"""
|
|
|
283 |
|
284 |
# Right Column
|
285 |
with antd.Col(span=24, md=16):
|
286 |
+
with antd.Card(
|
287 |
+
title="Output",
|
288 |
+
elem_style=dict(height="100%",
|
289 |
+
display="flex",
|
290 |
+
flexDirection="column"),
|
291 |
+
styles=dict(body=dict(height=0, flex=1)),
|
292 |
+
elem_id="output-container"):
|
293 |
# Output Container Extra
|
294 |
with ms.Slot("extra"):
|
295 |
with ms.Div(elem_id="output-container-extra"):
|
|
|
307 |
"🧑💻 View Code", type="primary")
|
308 |
# Output Content
|
309 |
with antd.Tabs(
|
310 |
+
elem_style=dict(height="100%"),
|
311 |
active_key="empty",
|
312 |
render_tab_bar="() => null") as state_tab:
|
313 |
with antd.Tabs.Item(key="empty"):
|
|
|
343 |
placement="right",
|
344 |
get_container=
|
345 |
"() => document.querySelector('.gradio-container')",
|
346 |
+
elem_id="coder-artifacts-code-drawer",
|
347 |
styles=dict(
|
348 |
body=dict(display="flex",
|
349 |
flexDirection="column-reverse")),
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
modelscope_studio==1.4.
|
2 |
openai
|
|
|
1 |
+
modelscope_studio==1.4.5
|
2 |
openai
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "modelscope_studio"
|
11 |
-
version = "1.4.
|
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.4.5"
|
12 |
description = "A third-party component library based on Gradio."
|
13 |
readme = "README.md"
|
14 |
license = "Apache-2.0"
|