Spaces:
Running
Running
feat: update
Browse files- app.py +11 -2
- components/antdx/attachments/README-zh_CN.md +8 -0
- components/antdx/attachments/README.md +8 -0
- components/antdx/attachments/app.py +6 -0
- components/antdx/attachments/demos/basic.py +50 -0
- components/antdx/attachments/demos/combination.py +74 -0
- components/antdx/attachments/demos/file_card.py +0 -0
- layout_templates/coder_artifacts/demos/app.py +4 -4
- 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 = [{
|
@@ -411,6 +411,15 @@ antdx_menu_items = [{
|
|
411 |
"label": get_text("Prompts", "Prompts 提示集"),
|
412 |
"key": "prompts"
|
413 |
}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
}]
|
415 |
|
416 |
|
@@ -484,7 +493,7 @@ site = Site(
|
|
484 |
# match the key of tabs
|
485 |
"index": index_docs,
|
486 |
"antd": antd_docs,
|
487 |
-
|
488 |
"base": base_docs
|
489 |
},
|
490 |
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 = [{
|
|
|
411 |
"label": get_text("Prompts", "Prompts 提示集"),
|
412 |
"key": "prompts"
|
413 |
}]
|
414 |
+
}, {
|
415 |
+
"label":
|
416 |
+
get_text("Express", "表达"),
|
417 |
+
"type":
|
418 |
+
"group",
|
419 |
+
"children": [{
|
420 |
+
"label": get_text("Attachments", "Attachments 输入附件"),
|
421 |
+
"key": "attachments"
|
422 |
+
}]
|
423 |
}]
|
424 |
|
425 |
|
|
|
493 |
# match the key of tabs
|
494 |
"index": index_docs,
|
495 |
"antd": antd_docs,
|
496 |
+
"antdx": antdx_docs,
|
497 |
"base": base_docs
|
498 |
},
|
499 |
default_active_tab=default_active_tab,
|
components/antdx/attachments/README-zh_CN.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Attachments
|
2 |
+
|
3 |
+
Display the collection of attachment information. See [Ant Design X](https://x.ant.design/components/attachments/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="combination" title="Combination"></demo>
|
components/antdx/attachments/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Attachments
|
2 |
+
|
3 |
+
Display the collection of attachment information. See [Ant Design X](https://x.ant.design/components/attachments/) for more information.
|
4 |
+
|
5 |
+
## Examples
|
6 |
+
|
7 |
+
<demo name="basic"></demo>
|
8 |
+
<demo name="combination" title="Combination"></demo>
|
components/antdx/attachments/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/attachments/demos/basic.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 upload_file(attachments_value):
|
8 |
+
print(attachments_value)
|
9 |
+
|
10 |
+
|
11 |
+
default_fullscreen_drop = False
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
with ms.Application():
|
15 |
+
with antdx.XProvider():
|
16 |
+
with antd.Flex(vertical=True,
|
17 |
+
gap="middle",
|
18 |
+
align="flex-start",
|
19 |
+
elem_id="attachments-container"):
|
20 |
+
fullscreen_drop_switch = antd.Switch(
|
21 |
+
value=default_fullscreen_drop,
|
22 |
+
checked_children="Full screen drop",
|
23 |
+
un_checked_children="Full screen drop")
|
24 |
+
with antdx.Sender():
|
25 |
+
with ms.Slot("prefix"):
|
26 |
+
with antdx.Attachments(
|
27 |
+
placeholder=dict(
|
28 |
+
title="Drag & Drop files here",
|
29 |
+
description=
|
30 |
+
"Support file type: image, video, audio, document, etc."
|
31 |
+
),
|
32 |
+
get_drop_container=
|
33 |
+
"() => document.querySelector('#attachments-container')",
|
34 |
+
) as attachments:
|
35 |
+
with antd.Button(value=None, type="text"):
|
36 |
+
with ms.Slot("icon"):
|
37 |
+
antd.Icon("LinkOutlined")
|
38 |
+
with ms.Slot("placeholder.icon"):
|
39 |
+
antd.Icon("CloudUploadOutlined")
|
40 |
+
|
41 |
+
attachments.change(fn=upload_file, inputs=[attachments])
|
42 |
+
fullscreen_drop_switch.change(fn=lambda x: gr.update(
|
43 |
+
get_drop_container="() => document.body" if x else
|
44 |
+
"() => document.querySelector('#attachments-container')",
|
45 |
+
),
|
46 |
+
inputs=[fullscreen_drop_switch],
|
47 |
+
outputs=[attachments])
|
48 |
+
|
49 |
+
if __name__ == "__main__":
|
50 |
+
demo.queue().launch()
|
components/antdx/attachments/demos/combination.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 toggle_open(state_value, attachments_value):
|
8 |
+
state_value["open"] = not state_value["open"]
|
9 |
+
return gr.update(open=state_value["open"]), gr.update(
|
10 |
+
dot=len(attachments_value) > 0 and not state_value["open"]), gr.update(
|
11 |
+
value=state_value)
|
12 |
+
|
13 |
+
|
14 |
+
def submit(sender_value, attachments_value):
|
15 |
+
print(sender_value, attachments_value)
|
16 |
+
return gr.update(value=None), gr.update(value=None), gr.update(dot=False)
|
17 |
+
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
state = gr.State({"open": True})
|
21 |
+
with ms.Application():
|
22 |
+
with antdx.XProvider():
|
23 |
+
antd.Typography.Paragraph(
|
24 |
+
"Work with Sender.Header to insert file into the conversation."
|
25 |
+
)
|
26 |
+
with antdx.Sender() as sender:
|
27 |
+
with ms.Slot("prefix"):
|
28 |
+
with antd.Badge(dot=False) as prefix_badge:
|
29 |
+
with antd.Button(value=None) as prefix_button:
|
30 |
+
with ms.Slot("icon"):
|
31 |
+
antd.Icon("LinkOutlined")
|
32 |
+
with ms.Slot("header"):
|
33 |
+
with antdx.Sender.Header(title="Attachments",
|
34 |
+
open=True,
|
35 |
+
styles={
|
36 |
+
"content": {
|
37 |
+
"padding": 0,
|
38 |
+
},
|
39 |
+
}) as sender_header:
|
40 |
+
with antdx.Attachments() as attachments:
|
41 |
+
with ms.Slot(
|
42 |
+
"placeholder.title",
|
43 |
+
params_mapping=
|
44 |
+
"""(type) => type === 'drop' ? 'Drop file here' : 'Upload files'"""
|
45 |
+
):
|
46 |
+
ms.Span()
|
47 |
+
with ms.Slot(
|
48 |
+
"placeholder.description",
|
49 |
+
params_mapping=
|
50 |
+
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })"
|
51 |
+
):
|
52 |
+
ms.Span(
|
53 |
+
"Click or drag files to this area to upload"
|
54 |
+
)
|
55 |
+
with ms.Slot(
|
56 |
+
"placeholder.icon",
|
57 |
+
params_mapping=
|
58 |
+
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })"
|
59 |
+
):
|
60 |
+
antd.Icon("CloudUploadOutlined")
|
61 |
+
|
62 |
+
sender_header.open_change(
|
63 |
+
fn=toggle_open,
|
64 |
+
inputs=[state, attachments],
|
65 |
+
outputs=[sender_header, prefix_badge, state])
|
66 |
+
prefix_button.click(fn=toggle_open,
|
67 |
+
inputs=[state, attachments],
|
68 |
+
outputs=[sender_header, prefix_badge, state])
|
69 |
+
sender.submit(fn=submit,
|
70 |
+
inputs=[sender, attachments],
|
71 |
+
outputs=[sender, attachments, prefix_badge])
|
72 |
+
|
73 |
+
if __name__ == "__main__":
|
74 |
+
demo.queue().launch()
|
components/antdx/attachments/demos/file_card.py
ADDED
File without changes
|
layout_templates/coder_artifacts/demos/app.py
CHANGED
@@ -15,6 +15,7 @@ MODELSCOPE_ACCESS_TOKEN = os.getenv('MODELSCOPE_ACCESS_TOKEN')
|
|
15 |
client = OpenAI(api_key=MODELSCOPE_ACCESS_TOKEN,
|
16 |
base_url="https://api-inference.modelscope.cn/v1")
|
17 |
|
|
|
18 |
# =========== Configuration
|
19 |
|
20 |
DEFAULT_SYSTEM_PROMPT = """You are a web development engineer, writing web pages according to the instructions below. You are a powerful code editing assistant capable of writing code and creating artifacts in conversations with users, or modifying and updating existing artifacts as requested by users.
|
@@ -87,10 +88,9 @@ class GradioEvents:
|
|
87 |
|
88 |
messages.append({'role': "user", 'content': input_value})
|
89 |
|
90 |
-
generator = client.chat.completions.create(
|
91 |
-
|
92 |
-
|
93 |
-
stream=True)
|
94 |
response = ""
|
95 |
for chunk in generator:
|
96 |
content = chunk.choices[0].delta.content
|
|
|
15 |
client = OpenAI(api_key=MODELSCOPE_ACCESS_TOKEN,
|
16 |
base_url="https://api-inference.modelscope.cn/v1")
|
17 |
|
18 |
+
model = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
19 |
# =========== Configuration
|
20 |
|
21 |
DEFAULT_SYSTEM_PROMPT = """You are a web development engineer, writing web pages according to the instructions below. You are a powerful code editing assistant capable of writing code and creating artifacts in conversations with users, or modifying and updating existing artifacts as requested by users.
|
|
|
88 |
|
89 |
messages.append({'role': "user", 'content': input_value})
|
90 |
|
91 |
+
generator = client.chat.completions.create(model=model,
|
92 |
+
messages=messages,
|
93 |
+
stream=True)
|
|
|
94 |
response = ""
|
95 |
for chunk in generator:
|
96 |
content = chunk.choices[0].delta.content
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
modelscope_studio==1.1.
|
2 |
openai
|
|
|
1 |
+
modelscope_studio==1.1.2
|
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.2"
|
12 |
description = "A third-party component library based on Gradio."
|
13 |
readme = "README.md"
|
14 |
license = "Apache-2.0"
|