-
-
- ✖️
-
-
-
- -
-GitHub | 🤖 ModelScope Studio | 🤗 Hugging Face Space
-
-`modelscope_studio` 是一套基于 gradio 4.x 的扩展组件库,致力于服务于 ModelScope 创空间中对于 gradio 应用的各类扩展需求,目前主要聚集在对话场景增强、多模态场景以及一些其他垂直场景支持。
-
-## Install
-
-```sh
-pip install modelscope_studio
-```
-
-## API
-
--
-
-
- ✖️
-
-
-
- -
-GitHub | 🤖 ModelScope Studio | 🤗 Hugging Face Space
-
-`modelscope_studio` is a set of extension component libraries based on gradio 4.x, dedicated to serving the various extension needs of gradio applications within the ModelScope Studio. It mainly focuses on enhancing conversational scenarios, supporting multimodal contexts, and providing assistance for various other specialized scenarios.
-
-## Install
-
-```sh
-pip install modelscope_studio
-```
-
-## API
-
--
- 如果传入 int, 则应用于所有尺寸屏幕;
- 如果传入 tuple, 当给出的断点少于 6 个, 则最后一个断点将用于所有后续断点;
- 如果传入 dict, 则可以以 [xs,sm,md,lg,xl,xll] 为键表示每个尺寸屏幕的图像数量。 |
-| gap | tuple \| int | 8 | 图片之间的间隙 (px)。 如果传递一个元组,则第一个值是宽度的间隙,第二个值是高度的间隙。如果传递数字,则宽度和高度的间隙相同 |
-| action_label | str | 'Click' | action 按钮的文案。当 `clickable`为 True 时才展示 |
-| likeable | bool | None | 是否显示喜欢或不喜欢按钮。 可以通过显示绑定 `.like` 方法自动设置。 |
-| clickable | bool | None | 是否显示 action 按钮。 可以通过显示绑定 `.click` 方法自动设置。 |
-
-### event listeners
-
-| 事件 | 描述 |
-| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `mgr.WaterfallGallery.load_more(fn, ···)` | “加载更多”按钮被点击时触发。 |
-| `mgr.WaterfallGallery.like(fn, ···)` | 当点赞/点踩按钮被点击时触发,EventData 为:
- index:当前图片索引。
- value:当前图片信息。
- liked:当前图片的喜欢/不喜欢状态,可以为 None,代表用户取消操作。 |
-| `mgr.WaterfallGallery.click(fn, ···)` | action 按钮被点击时触发,EventData 为:
- index:当前图片索引。
- value:当前图片信息。 |
diff --git a/components/legacy/WaterfallGallery/README.md b/components/legacy/WaterfallGallery/README.md
deleted file mode 100644
index 392fe320a45a75d44b8f0111deb73e4a1021da23..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/README.md
+++ /dev/null
@@ -1,71 +0,0 @@
-# WaterfallGallery
-
-gradio Gallery with waterfall flow.
-
-- Support waterfall flow display images
-- Added a like button, support additional binding of `like` events to images
-- Added an action button, support additional binding of `click` event to images
-- Responsive columns
-
-## How to Use
-
-### Basic Usage
-
-
- If int is passed in, it will apply to all screen sizes;
- If tuple is passed in, when less than 6 breakpoints are given, the last breakpoint will be used for all subsequent breakpoints ;
- If a dict is passed in, you can represents the number of images for each size screen with [xs,sm,md,lg,xl,xll] as the key. |
-| gap | tuple \| int | 8 | The gap (px) between images. If a tuple is passed, the first value is the gap for width and the second value is the gap for height.If a number is passed, the gap will be the same for width and height. |
-| action_label | str | 'Click' | The label for the action button. Only displayed if `clickable` is set to True. |
-| likeable | bool | None | Whether the gallery image display a like or dislike button. Set automatically by the .like method but has to be present in the signature for it to show up in the config. |
-| clickable | bool | None | Whether the gallery image display an action button. Set automatically by the .click method but has to be present in the signature for it to show up in the config. |
-
-### Event Listeners
-
-| Event | Description |
-| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `mgr.WaterfallGallery.load_more(fn, ···)` | Triggered when the "Load More" button is clicked. |
-| `mgr.WaterfallGallery.like(fn, ···)` | Triggered when the Like/Dislike button is clicked. EventData is:
- index: current image index.
- value: current image info.
- liked: like/dislike status of the current image, which can be None, indicating that the user cancels the operation. |
-| `mgr.WaterfallGallery.click(fn, ···)` | Triggered when the action button is clicked, EventData is:
- index: current image index.
- value: current image info. |
diff --git a/components/legacy/WaterfallGallery/app.py b/components/legacy/WaterfallGallery/app.py
deleted file mode 100644
index ea841f78832d9254426dc781674f7e39f7f7fd2f..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/app.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from components.legacy.Docs import Docs
-
-docs = Docs(__file__)
-
-if __name__ == "__main__":
- docs.render().queue().launch()
diff --git a/components/legacy/WaterfallGallery/demos/basic.py b/components/legacy/WaterfallGallery/demos/basic.py
deleted file mode 100644
index 1071ef06844b4f3399f35a1325e318f34cb92699..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/demos/basic.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import os
-
-import gradio as gr
-import modelscope_studio.components.base as ms
-import modelscope_studio.components.legacy as mgr
-
-
-def resolve_assets(relative_path):
- return os.path.join(os.path.dirname(__file__), "../../resources",
- relative_path)
-
-
-with gr.Blocks() as demo, ms.Application():
- mgr.WaterfallGallery(
- value=[
- resolve_assets('modelscope.svg'),
- # pass a tuple
- [resolve_assets('bot.jpeg'), 'bot'],
- # pass a dict
- {
- "image": resolve_assets('user.jpeg'),
- "caption": "user",
- },
- resolve_assets('screen.jpeg'),
- ],
- columns=2,
- height=600)
-
-if __name__ == "__main__":
- demo.queue().launch()
diff --git a/components/legacy/WaterfallGallery/demos/like_click_feedback.py b/components/legacy/WaterfallGallery/demos/like_click_feedback.py
deleted file mode 100644
index 64299d854f90c963bd1b953871b488490d6e7839..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/demos/like_click_feedback.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import os
-
-import gradio as gr
-import modelscope_studio.components.base as ms
-import modelscope_studio.components.legacy as mgr
-
-
-def resolve_assets(relative_path):
- return os.path.join(os.path.dirname(__file__), "../../resources",
- relative_path)
-
-
-def fn(data: gr.EventData):
- print(data._data)
-
-
-with gr.Blocks() as demo, ms.Application():
- gallery = mgr.WaterfallGallery(
- value=[
- resolve_assets('modelscope.svg'),
- # pass a tuple
- [resolve_assets('bot.jpeg'), 'bot'],
- # pass a dict
- {
- "image": resolve_assets('user.jpeg'),
- "caption": "user",
- },
- resolve_assets('screen.jpeg'),
- ],
- action_label="Click Me!",
- columns=2,
- height=600)
- gallery.like(fn=fn)
- gallery.click(fn=fn)
-
-if __name__ == "__main__":
- demo.queue().launch()
diff --git a/components/legacy/WaterfallGallery/demos/load_more.py b/components/legacy/WaterfallGallery/demos/load_more.py
deleted file mode 100644
index 28fe008ec3f99005cbc97d523ceac1019afc3a6f..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/demos/load_more.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import os
-import time
-
-import gradio as gr
-import modelscope_studio.components.base as ms
-import modelscope_studio.components.legacy as mgr
-
-
-def resolve_assets(relative_path):
- return os.path.join(os.path.dirname(__file__), "../../resources",
- relative_path)
-
-
-def load_more(_gallery):
- time.sleep(1)
- _gallery.append(resolve_assets('modelscope.svg'))
- _gallery.append(resolve_assets('bot.jpeg'))
- _gallery.append(resolve_assets('user.jpeg'))
- _gallery.append(resolve_assets('screen.jpeg'))
- has_more = True
- if (len(_gallery) > 10):
- has_more = False
- return gr.update(value=_gallery, has_more=has_more)
-
-
-with gr.Blocks() as demo, ms.Application():
- gallery = mgr.WaterfallGallery(
- value=[
- resolve_assets('modelscope.svg'),
- # pass a tuple
- [resolve_assets('bot.jpeg'), 'bot'],
- # pass a dict
- {
- "image": resolve_assets('user.jpeg'),
- "caption": "user",
- },
- resolve_assets('screen.jpeg'),
- ],
- has_more=True,
- columns=2,
- height=600)
- gallery.load_more(fn=load_more, inputs=[gallery], outputs=[gallery])
-
-if __name__ == "__main__":
- demo.queue().launch()
diff --git a/components/legacy/WaterfallGallery/demos/responsive_columns.py b/components/legacy/WaterfallGallery/demos/responsive_columns.py
deleted file mode 100644
index dcea88d8e18c7e24e9fd89be7638826f91e417cb..0000000000000000000000000000000000000000
--- a/components/legacy/WaterfallGallery/demos/responsive_columns.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import os
-
-import gradio as gr
-import modelscope_studio.components.base as ms
-import modelscope_studio.components.legacy as mgr
-
-
-def resolve_assets(relative_path):
- return os.path.join(os.path.dirname(__file__), "../../resources",
- relative_path)
-
-
-def fn():
- return gr.update(columns={"xs": 2, "lg": 3})
-
-
-with gr.Blocks() as demo, ms.Application():
- gallery = mgr.WaterfallGallery(
- value=[
- resolve_assets('modelscope.svg'),
- # pass a tuple
- [resolve_assets('bot.jpeg'), 'bot'],
- # pass a dict
- {
- "image": resolve_assets('user.jpeg'),
- "caption": "user",
- },
- resolve_assets('screen.jpeg'),
- ],
- columns=[2, 3, 4],
- height=600)
- gr.Button("Update Columns").click(fn=fn, outputs=[gallery])
-
-if __name__ == "__main__":
- demo.queue().launch()
diff --git a/components/legacy/app.py b/components/legacy/app.py
deleted file mode 100644
index 3606901af2b5fa0e4dd0244818fe5e4b9b9df35d..0000000000000000000000000000000000000000
--- a/components/legacy/app.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import gradio as gr
-import modelscope_studio.components.base as ms
-from api.app import docs as api_docs
-from components.legacy.Chatbot.app import docs as chatbot_docs
-from components.legacy.Docs import Docs
-from components.legacy.Flow.app import docs as flow_docs
-from components.legacy.Lifecycle.app import docs as lifecycle_docs
-from components.legacy.Markdown.app import docs as markdown_docs
-from components.legacy.MultimodalInput.app import docs as multimodel_input_docs
-from components.legacy.WaterfallGallery.app import \
- docs as waterfall_gallery_docs
-
-readme_docs = Docs(__file__)
-
-docs = [
- ["Quick Start", readme_docs],
- ["API", api_docs],
- ["Chatbot", chatbot_docs],
- ["MultimodalInput", multimodel_input_docs],
- ["Markdown", markdown_docs],
- ["Lifecycle", lifecycle_docs],
- ["WaterfallGallery", waterfall_gallery_docs],
- ["Flow", flow_docs],
-]
-
-with gr.Blocks() as legacy_demo:
- with ms.Application():
- with gr.Tabs() as components_tabs:
- for doc in docs:
- with gr.TabItem(doc[0], id=doc[0]):
- doc[1].render(components_tabs)
-
-if __name__ == "__main__":
- legacy_demo.launch()
diff --git a/components/legacy/parse_markdown.py b/components/legacy/parse_markdown.py
deleted file mode 100644
index 56074f51585def881aa974994f2fa944c335c8ac..0000000000000000000000000000000000000000
--- a/components/legacy/parse_markdown.py
+++ /dev/null
@@ -1,85 +0,0 @@
-from html.parser import HTMLParser
-
-
-def default_read_file(path):
- with open(path, "r") as f:
- return f.read()
-
-
-enable_tags = ["demo", "demo-prefix", "demo-suffix", "file"]
-
-
-class MarkdownParser(HTMLParser):
-
- def __init__(self, read_file=None):
- super().__init__()
- self.value = [{"type": "text", "value": ""}]
- self.tag_stack = []
- self.read_file = read_file or default_read_file
- self.current_tag = None
-
- def get_value(self):
- return self.value
-
- def handle_data(self, data: str) -> None:
- if self.value[-1]["type"] == "text":
- self.value[-1]["value"] += data
- elif self.current_tag is None:
- self.value.append({"type": "text", "value": data})
- elif self.current_tag == "demo-prefix":
- self.value[-1]["prefix"] += data
- elif self.current_tag == "demo-suffix":
- self.value[-1]["suffix"] += data
-
- def handle_startendtag(self, tag: str, attrs) -> None:
- if tag not in enable_tags:
- self.handle_data(self.get_starttag_text())
- return
-
- def handle_starttag(self, tag: str, attrs) -> None:
- if (tag not in enable_tags):
- self.handle_data(self.get_starttag_text())
- return
- if tag == "demo":
- self.value.append({
- "type":
- "demo",
- "code_position":
- dict(attrs).get("code-position", 'left'),
- "name":
- dict(attrs)["name"],
- "prefix":
- "",
- "suffix":
- ""
- })
- elif tag == "file":
- content = self.read_file(dict(attrs)["src"])
- if self.value[-1]["type"] == "text":
- self.value[-1]["value"] += content
- elif self.current_tag == "demo-prefix":
- self.value[-1]["prefix"] += content
- elif self.current_tag == "demo-suffix":
- self.value[-1]["suffix"] += content
- self.current_tag = tag
- self.tag_stack.append(self.current_tag)
-
- def handle_endtag(self, tag: str) -> None:
-
- if (tag not in enable_tags):
- self.handle_data(f"{tag}>")
- return
- if (len(self.tag_stack) > 0):
- self.tag_stack.pop()
- if (len(self.tag_stack) > 0):
- self.current_tag = self.tag_stack[-1]
- else:
- self.current_tag = None
- else:
- self.current_tag = None
-
-
-def parse_markdown(markdown: str, read_file=None):
- parser = MarkdownParser(read_file=read_file)
- parser.feed(markdown)
- return parser.get_value()
diff --git a/components/legacy/resources/audio.wav b/components/legacy/resources/audio.wav
deleted file mode 100644
index 105190ad88e2e177540361de340e54feb1587f3c..0000000000000000000000000000000000000000
Binary files a/components/legacy/resources/audio.wav and /dev/null differ
diff --git a/components/legacy/resources/bot.jpeg b/components/legacy/resources/bot.jpeg
deleted file mode 100644
index 5fde8cc45f61b677c0581e6889b11e269c35be08..0000000000000000000000000000000000000000
Binary files a/components/legacy/resources/bot.jpeg and /dev/null differ
diff --git a/components/legacy/resources/custom_components/custom_select.js b/components/legacy/resources/custom_components/custom_select.js
deleted file mode 100644
index f4a1cb405ae5efb33e31990018b2beac5ac26aa3..0000000000000000000000000000000000000000
--- a/components/legacy/resources/custom_components/custom_select.js
+++ /dev/null
@@ -1,29 +0,0 @@
-(props, cc, { el, onUpdate }) => {
- const options = JSON.parse(props.options);
- el.innerHTML = `
- ${options
- .map((option) => {
- return `