Commit
•
878d1fe
1
Parent(s):
cca3971
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- Dockerfile +12 -0
- README.md +6 -6
- __init__.py +0 -0
- __pycache__/app.cpython-310.pyc +0 -0
- app.py +29 -0
- cantina.wav +0 -0
- requirements.txt +1 -0
- src/.gitignore +9 -0
- src/README.md +10 -0
- src/backend/gradio_multimodalchatbot/__init__.py +4 -0
- src/backend/gradio_multimodalchatbot/multimodalchatbot.py +177 -0
- src/backend/gradio_multimodalchatbot/multimodalchatbot.pyi +289 -0
- src/backend/gradio_multimodalchatbot/templates/component/index.js +0 -0
- src/backend/gradio_multimodalchatbot/templates/component/style.css +0 -0
- src/demo/__init__.py +0 -0
- src/demo/app.py +29 -0
- src/demo/cantina.wav +0 -0
- src/demo/world.mp4 +3 -0
- src/frontend/Index.svelte +158 -0
- src/frontend/package-lock.json +1096 -0
- src/frontend/package.json +29 -0
- src/frontend/shared/ChatBot.svelte +553 -0
- src/frontend/shared/Copy.svelte +73 -0
- src/frontend/shared/LikeDislike.svelte +49 -0
- src/frontend/shared/Pending.svelte +46 -0
- src/frontend/shared/autorender.d.ts +1 -0
- src/frontend/shared/utils.ts +69 -0
- src/pyproject.toml +49 -0
- world.mp4 +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
src/demo/world.mp4 filter=lfs diff=lfs merge=lfs -text
|
37 |
+
world.mp4 filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
WORKDIR /code
|
5 |
+
|
6 |
+
COPY --link --chown=1000 . .
|
7 |
+
|
8 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
9 |
+
|
10 |
+
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
11 |
+
|
12 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: docker
|
7 |
pinned: false
|
|
|
8 |
---
|
9 |
-
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
tags: [gradio-custom-component, gradio-template-Chatbot]
|
4 |
+
title: gradio_multimodalchatbot V0.0.1
|
5 |
+
colorFrom: purple
|
6 |
+
colorTo: indigo
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
+
license: apache-2.0
|
10 |
---
|
|
|
|
__init__.py
ADDED
File without changes
|
__pycache__/app.cpython-310.pyc
ADDED
Binary file (955 Bytes). View file
|
|
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_multimodalchatbot import MultimodalChatbot
|
4 |
+
from gradio.data_classes import FileData
|
5 |
+
|
6 |
+
user_msg1 = {"text": "Hello, what is in this image?",
|
7 |
+
"files": [{"file": FileData(path="https://gradio-builds.s3.amazonaws.com/diffusion_image/cute_dog.jpg")}]
|
8 |
+
}
|
9 |
+
bot_msg1 = {"text": "It is a very cute dog",
|
10 |
+
"files": []}
|
11 |
+
|
12 |
+
user_msg2 = {"text": "Describe this audio clip please.",
|
13 |
+
"files": [{"file": FileData(path="cantina.wav")}]}
|
14 |
+
bot_msg2 = {"text": "It is the cantina song from Star Wars",
|
15 |
+
"files": []}
|
16 |
+
|
17 |
+
user_msg3 = {"text": "Give me a video clip please.",
|
18 |
+
"files": []}
|
19 |
+
bot_msg3 = {"text": "Here is a video clip of the world",
|
20 |
+
"files": [{"file": FileData(path="world.mp4")},
|
21 |
+
{"file": FileData(path="cantina.wav")}]}
|
22 |
+
|
23 |
+
conversation = [[user_msg1, bot_msg1], [user_msg2, bot_msg2], [user_msg3, bot_msg3]]
|
24 |
+
|
25 |
+
with gr.Blocks() as demo:
|
26 |
+
MultimodalChatbot(value=conversation)
|
27 |
+
|
28 |
+
|
29 |
+
demo.launch()
|
cantina.wav
ADDED
Binary file (132 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_multimodalchatbot-0.0.1-py3-none-any.whl
|
src/.gitignore
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
node_modules
|
src/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# gradio_multimodalchatbot
|
3 |
+
A Custom Gradio component.
|
4 |
+
|
5 |
+
## Example usage
|
6 |
+
|
7 |
+
```python
|
8 |
+
import gradio as gr
|
9 |
+
from gradio_multimodalchatbot import MultimodalChatbot
|
10 |
+
```
|
src/backend/gradio_multimodalchatbot/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .multimodalchatbot import MultimodalChatbot
|
3 |
+
|
4 |
+
__all__ = ['MultimodalChatbot']
|
src/backend/gradio_multimodalchatbot/multimodalchatbot.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Chatbot() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import inspect
|
6 |
+
from pathlib import Path
|
7 |
+
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
8 |
+
|
9 |
+
from gradio_client import utils as client_utils
|
10 |
+
|
11 |
+
from gradio import utils
|
12 |
+
from gradio.components.base import Component
|
13 |
+
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
14 |
+
from gradio.events import Events
|
15 |
+
|
16 |
+
|
17 |
+
class FileMessage(GradioModel):
|
18 |
+
file: FileData
|
19 |
+
alt_text: Optional[str] = None
|
20 |
+
|
21 |
+
|
22 |
+
class MultimodalMessage(GradioModel):
|
23 |
+
text: Optional[str] = None
|
24 |
+
files: Optional[List[FileMessage]] = None
|
25 |
+
|
26 |
+
|
27 |
+
class ChatbotData(GradioRootModel):
|
28 |
+
root: List[Tuple[Optional[MultimodalMessage], Optional[MultimodalMessage]]]
|
29 |
+
|
30 |
+
|
31 |
+
class MultimodalChatbot(Component):
|
32 |
+
"""
|
33 |
+
Displays a chatbot output showing both user submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables. Also supports audio/video/image files, which are displayed in the MultimodalChatbot, and other kinds of files which are displayed as links.
|
34 |
+
Preprocessing: passes the messages in the MultimodalChatbot as a {List[List[str | None | Tuple]]}, i.e. a list of lists. The inner list has 2 elements: the user message and the response message. See `Postprocessing` for the format of these messages.
|
35 |
+
Postprocessing: expects function to return a {List[List[str | None | Tuple]]}, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultimodalChatbot, or (3) None, in which case the message is not displayed.
|
36 |
+
|
37 |
+
Demos: chatbot_simple, chatbot_multimodal
|
38 |
+
Guides: creating-a-chatbot
|
39 |
+
"""
|
40 |
+
|
41 |
+
EVENTS = [Events.change, Events.select, Events.like]
|
42 |
+
data_model = ChatbotData
|
43 |
+
|
44 |
+
def __init__(
|
45 |
+
self,
|
46 |
+
value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
|
47 |
+
| Callable
|
48 |
+
| None = None,
|
49 |
+
*,
|
50 |
+
label: str | None = None,
|
51 |
+
every: float | None = None,
|
52 |
+
show_label: bool | None = None,
|
53 |
+
container: bool = True,
|
54 |
+
scale: int | None = None,
|
55 |
+
min_width: int = 160,
|
56 |
+
visible: bool = True,
|
57 |
+
elem_id: str | None = None,
|
58 |
+
elem_classes: list[str] | str | None = None,
|
59 |
+
render: bool = True,
|
60 |
+
height: int | None = None,
|
61 |
+
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
62 |
+
rtl: bool = False,
|
63 |
+
show_share_button: bool | None = None,
|
64 |
+
show_copy_button: bool = False,
|
65 |
+
avatar_images: tuple[str | Path | None, str | Path | None] | None = None,
|
66 |
+
sanitize_html: bool = True,
|
67 |
+
render_markdown: bool = True,
|
68 |
+
bubble_full_width: bool = True,
|
69 |
+
line_breaks: bool = True,
|
70 |
+
likeable: bool = False,
|
71 |
+
layout: Literal["panel", "bubble"] | None = None,
|
72 |
+
):
|
73 |
+
"""
|
74 |
+
Parameters:
|
75 |
+
value: Default value to show in chatbot. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
76 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
77 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
78 |
+
show_label: if True, will display label.
|
79 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
80 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
81 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
82 |
+
visible: If False, component will be hidden.
|
83 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
84 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
85 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
86 |
+
height: height of the component in pixels.
|
87 |
+
latex_delimiters: A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions enclosed in $$ delimiters will be rendered as LaTeX, and in a new line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html).
|
88 |
+
rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
|
89 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
90 |
+
show_copy_button: If True, will show a copy button for each chatbot message.
|
91 |
+
avatar_images: Tuple of two avatar image paths or URLs for user and bot (in that order). Pass None for either the user or bot image to skip. Must be within the working directory of the Gradio app or an external URL.
|
92 |
+
sanitize_html: If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.
|
93 |
+
render_markdown: If False, will disable Markdown rendering for chatbot messages.
|
94 |
+
bubble_full_width: If False, the chat bubble will fit to the content of the message. If True (default), the chat bubble will be the full width of the component.
|
95 |
+
line_breaks: If True (default), will enable Github-flavored Markdown line breaks in chatbot messages. If False, single new lines will be ignored. Only applies if `render_markdown` is True.
|
96 |
+
likeable: Whether the chat messages 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.
|
97 |
+
layout: If "panel", will display the chatbot in a llm style layout. If "bubble", will display the chatbot with message bubbles, with the user and bot messages on alterating sides. Will default to "bubble".
|
98 |
+
"""
|
99 |
+
self.likeable = likeable
|
100 |
+
self.height = height
|
101 |
+
self.rtl = rtl
|
102 |
+
if latex_delimiters is None:
|
103 |
+
latex_delimiters = [{"left": "$$", "right": "$$", "display": True}]
|
104 |
+
self.latex_delimiters = latex_delimiters
|
105 |
+
self.avatar_images = avatar_images or (None, None)
|
106 |
+
self.show_share_button = (
|
107 |
+
(utils.get_space() is not None)
|
108 |
+
if show_share_button is None
|
109 |
+
else show_share_button
|
110 |
+
)
|
111 |
+
self.render_markdown = render_markdown
|
112 |
+
self.show_copy_button = show_copy_button
|
113 |
+
self.sanitize_html = sanitize_html
|
114 |
+
self.bubble_full_width = bubble_full_width
|
115 |
+
self.line_breaks = line_breaks
|
116 |
+
self.layout = layout
|
117 |
+
|
118 |
+
super().__init__(
|
119 |
+
label=label,
|
120 |
+
every=every,
|
121 |
+
show_label=show_label,
|
122 |
+
container=container,
|
123 |
+
scale=scale,
|
124 |
+
min_width=min_width,
|
125 |
+
visible=visible,
|
126 |
+
elem_id=elem_id,
|
127 |
+
elem_classes=elem_classes,
|
128 |
+
render=render,
|
129 |
+
value=value,
|
130 |
+
)
|
131 |
+
|
132 |
+
def preprocess(
|
133 |
+
self,
|
134 |
+
payload: ChatbotData | None,
|
135 |
+
) -> List[MultimodalMessage] | None:
|
136 |
+
if payload is None:
|
137 |
+
return payload
|
138 |
+
return payload.root
|
139 |
+
|
140 |
+
def _postprocess_chat_messages(
|
141 |
+
self, chat_message: MultimodalMessage | dict | None
|
142 |
+
) -> MultimodalMessage | None:
|
143 |
+
if chat_message is None:
|
144 |
+
return None
|
145 |
+
if isinstance(chat_message, dict):
|
146 |
+
chat_message = MultimodalMessage(**chat_message)
|
147 |
+
chat_message.text = inspect.cleandoc(chat_message.text)
|
148 |
+
for file_ in chat_message.files:
|
149 |
+
file_.file.mime_type = client_utils.get_mimetype(file_.file.path)
|
150 |
+
return chat_message
|
151 |
+
|
152 |
+
def postprocess(
|
153 |
+
self,
|
154 |
+
value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple],
|
155 |
+
) -> ChatbotData:
|
156 |
+
if value is None:
|
157 |
+
return ChatbotData(root=[])
|
158 |
+
processed_messages = []
|
159 |
+
for message_pair in value:
|
160 |
+
if not isinstance(message_pair, (tuple, list)):
|
161 |
+
raise TypeError(
|
162 |
+
f"Expected a list of lists or list of tuples. Received: {message_pair}"
|
163 |
+
)
|
164 |
+
if len(message_pair) != 2:
|
165 |
+
raise TypeError(
|
166 |
+
f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
|
167 |
+
)
|
168 |
+
processed_messages.append(
|
169 |
+
[
|
170 |
+
self._postprocess_chat_messages(message_pair[0]),
|
171 |
+
self._postprocess_chat_messages(message_pair[1]),
|
172 |
+
]
|
173 |
+
)
|
174 |
+
return ChatbotData(root=processed_messages)
|
175 |
+
|
176 |
+
def example_inputs(self) -> Any:
|
177 |
+
return [[{"text": "Hello!", "files": []}, None]]
|
src/backend/gradio_multimodalchatbot/multimodalchatbot.pyi
ADDED
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Chatbot() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import inspect
|
6 |
+
from pathlib import Path
|
7 |
+
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
8 |
+
|
9 |
+
from gradio_client import utils as client_utils
|
10 |
+
from gradio_client.documentation import document, set_documentation_group
|
11 |
+
|
12 |
+
from gradio import utils
|
13 |
+
from gradio.components.base import Component
|
14 |
+
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
15 |
+
from gradio.events import Events
|
16 |
+
|
17 |
+
set_documentation_group("component")
|
18 |
+
|
19 |
+
|
20 |
+
class FileMessage(GradioModel):
|
21 |
+
file: FileData
|
22 |
+
alt_text: Optional[str] = None
|
23 |
+
|
24 |
+
|
25 |
+
class ChatbotData(GradioRootModel):
|
26 |
+
root: List[Tuple[Union[str, FileMessage, None], Union[str, FileMessage, None]]]
|
27 |
+
|
28 |
+
from gradio.events import Dependency
|
29 |
+
|
30 |
+
@document()
|
31 |
+
class MultimodalChatbot(Component):
|
32 |
+
"""
|
33 |
+
Displays a chatbot output showing both user submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables. Also supports audio/video/image files, which are displayed in the MultimodalChatbot, and other kinds of files which are displayed as links.
|
34 |
+
Preprocessing: passes the messages in the MultimodalChatbot as a {List[List[str | None | Tuple]]}, i.e. a list of lists. The inner list has 2 elements: the user message and the response message. See `Postprocessing` for the format of these messages.
|
35 |
+
Postprocessing: expects function to return a {List[List[str | None | Tuple]]}, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultimodalChatbot, or (3) None, in which case the message is not displayed.
|
36 |
+
|
37 |
+
Demos: chatbot_simple, chatbot_multimodal
|
38 |
+
Guides: creating-a-chatbot
|
39 |
+
"""
|
40 |
+
|
41 |
+
EVENTS = [Events.change, Events.select, Events.like]
|
42 |
+
data_model = ChatbotData
|
43 |
+
|
44 |
+
def __init__(
|
45 |
+
self,
|
46 |
+
value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
|
47 |
+
| Callable
|
48 |
+
| None = None,
|
49 |
+
*,
|
50 |
+
label: str | None = None,
|
51 |
+
every: float | None = None,
|
52 |
+
show_label: bool | None = None,
|
53 |
+
container: bool = True,
|
54 |
+
scale: int | None = None,
|
55 |
+
min_width: int = 160,
|
56 |
+
visible: bool = True,
|
57 |
+
elem_id: str | None = None,
|
58 |
+
elem_classes: list[str] | str | None = None,
|
59 |
+
render: bool = True,
|
60 |
+
height: int | None = None,
|
61 |
+
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
62 |
+
rtl: bool = False,
|
63 |
+
show_share_button: bool | None = None,
|
64 |
+
show_copy_button: bool = False,
|
65 |
+
avatar_images: tuple[str | Path | None, str | Path | None] | None = None,
|
66 |
+
sanitize_html: bool = True,
|
67 |
+
render_markdown: bool = True,
|
68 |
+
bubble_full_width: bool = True,
|
69 |
+
line_breaks: bool = True,
|
70 |
+
likeable: bool = False,
|
71 |
+
layout: Literal["panel", "bubble"] | None = None,
|
72 |
+
):
|
73 |
+
"""
|
74 |
+
Parameters:
|
75 |
+
value: Default value to show in chatbot. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
76 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
77 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
78 |
+
show_label: if True, will display label.
|
79 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
80 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
81 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
82 |
+
visible: If False, component will be hidden.
|
83 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
84 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
85 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
86 |
+
height: height of the component in pixels.
|
87 |
+
latex_delimiters: A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions enclosed in $$ delimiters will be rendered as LaTeX, and in a new line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html).
|
88 |
+
rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
|
89 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
90 |
+
show_copy_button: If True, will show a copy button for each chatbot message.
|
91 |
+
avatar_images: Tuple of two avatar image paths or URLs for user and bot (in that order). Pass None for either the user or bot image to skip. Must be within the working directory of the Gradio app or an external URL.
|
92 |
+
sanitize_html: If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.
|
93 |
+
render_markdown: If False, will disable Markdown rendering for chatbot messages.
|
94 |
+
bubble_full_width: If False, the chat bubble will fit to the content of the message. If True (default), the chat bubble will be the full width of the component.
|
95 |
+
line_breaks: If True (default), will enable Github-flavored Markdown line breaks in chatbot messages. If False, single new lines will be ignored. Only applies if `render_markdown` is True.
|
96 |
+
likeable: Whether the chat messages 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.
|
97 |
+
layout: If "panel", will display the chatbot in a llm style layout. If "bubble", will display the chatbot with message bubbles, with the user and bot messages on alterating sides. Will default to "bubble".
|
98 |
+
"""
|
99 |
+
self.likeable = likeable
|
100 |
+
self.height = height
|
101 |
+
self.rtl = rtl
|
102 |
+
if latex_delimiters is None:
|
103 |
+
latex_delimiters = [{"left": "$$", "right": "$$", "display": True}]
|
104 |
+
self.latex_delimiters = latex_delimiters
|
105 |
+
self.avatar_images = avatar_images or (None, None)
|
106 |
+
self.show_share_button = (
|
107 |
+
(utils.get_space() is not None)
|
108 |
+
if show_share_button is None
|
109 |
+
else show_share_button
|
110 |
+
)
|
111 |
+
self.render_markdown = render_markdown
|
112 |
+
self.show_copy_button = show_copy_button
|
113 |
+
self.sanitize_html = sanitize_html
|
114 |
+
self.bubble_full_width = bubble_full_width
|
115 |
+
self.line_breaks = line_breaks
|
116 |
+
self.layout = layout
|
117 |
+
|
118 |
+
super().__init__(
|
119 |
+
label=label,
|
120 |
+
every=every,
|
121 |
+
show_label=show_label,
|
122 |
+
container=container,
|
123 |
+
scale=scale,
|
124 |
+
min_width=min_width,
|
125 |
+
visible=visible,
|
126 |
+
elem_id=elem_id,
|
127 |
+
elem_classes=elem_classes,
|
128 |
+
render=render,
|
129 |
+
value=value,
|
130 |
+
)
|
131 |
+
|
132 |
+
def preprocess(
|
133 |
+
self,
|
134 |
+
payload: ChatbotData | None,
|
135 |
+
) -> List[MultimodalMessage] | None:
|
136 |
+
if payload is None:
|
137 |
+
return payload
|
138 |
+
return payload.root
|
139 |
+
|
140 |
+
def _postprocess_chat_messages(
|
141 |
+
self, chat_message: MultimodalMessage | dict | None
|
142 |
+
) -> MultimodalMessage | None:
|
143 |
+
if chat_message is None:
|
144 |
+
return None
|
145 |
+
if isinstance(chat_message, dict):
|
146 |
+
chat_message = MultimodalMessage(**chat_message)
|
147 |
+
chat_message.text = inspect.cleandoc(chat_message.text)
|
148 |
+
for file_ in chat_message.files:
|
149 |
+
file_.file.mime_type = client_utils.get_mimetype(file_.file.path)
|
150 |
+
return chat_message
|
151 |
+
|
152 |
+
def postprocess(
|
153 |
+
self,
|
154 |
+
value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple],
|
155 |
+
) -> ChatbotData:
|
156 |
+
if value is None:
|
157 |
+
return ChatbotData(root=[])
|
158 |
+
processed_messages = []
|
159 |
+
for message_pair in value:
|
160 |
+
if not isinstance(message_pair, (tuple, list)):
|
161 |
+
raise TypeError(
|
162 |
+
f"Expected a list of lists or list of tuples. Received: {message_pair}"
|
163 |
+
)
|
164 |
+
if len(message_pair) != 2:
|
165 |
+
raise TypeError(
|
166 |
+
f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
|
167 |
+
)
|
168 |
+
processed_messages.append(
|
169 |
+
[
|
170 |
+
self._postprocess_chat_messages(message_pair[0]),
|
171 |
+
self._postprocess_chat_messages(message_pair[1]),
|
172 |
+
]
|
173 |
+
)
|
174 |
+
return ChatbotData(root=processed_messages)
|
175 |
+
|
176 |
+
def example_inputs(self) -> Any:
|
177 |
+
return [[{"text": "Hello!", "files": []}, None]]
|
178 |
+
|
179 |
+
|
180 |
+
def change(self,
|
181 |
+
fn: Callable | None,
|
182 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
183 |
+
outputs: Component | Sequence[Component] | None = None,
|
184 |
+
api_name: str | None | Literal[False] = None,
|
185 |
+
status_tracker: None = None,
|
186 |
+
scroll_to_output: bool = False,
|
187 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
188 |
+
queue: bool | None = None,
|
189 |
+
batch: bool = False,
|
190 |
+
max_batch_size: int = 4,
|
191 |
+
preprocess: bool = True,
|
192 |
+
postprocess: bool = True,
|
193 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
194 |
+
every: float | None = None,
|
195 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
196 |
+
js: str | None = None,) -> Dependency:
|
197 |
+
"""
|
198 |
+
Parameters:
|
199 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
200 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
201 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
202 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
203 |
+
scroll_to_output: If True, will scroll to output component on completion
|
204 |
+
show_progress: If True, will show progress animation while pending
|
205 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
206 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
207 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
208 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
209 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
210 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
211 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
212 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
213 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
214 |
+
"""
|
215 |
+
...
|
216 |
+
|
217 |
+
def select(self,
|
218 |
+
fn: Callable | None,
|
219 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
220 |
+
outputs: Component | Sequence[Component] | None = None,
|
221 |
+
api_name: str | None | Literal[False] = None,
|
222 |
+
status_tracker: None = None,
|
223 |
+
scroll_to_output: bool = False,
|
224 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
225 |
+
queue: bool | None = None,
|
226 |
+
batch: bool = False,
|
227 |
+
max_batch_size: int = 4,
|
228 |
+
preprocess: bool = True,
|
229 |
+
postprocess: bool = True,
|
230 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
231 |
+
every: float | None = None,
|
232 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
233 |
+
js: str | None = None,) -> Dependency:
|
234 |
+
"""
|
235 |
+
Parameters:
|
236 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
237 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
238 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
239 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
240 |
+
scroll_to_output: If True, will scroll to output component on completion
|
241 |
+
show_progress: If True, will show progress animation while pending
|
242 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
243 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
244 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
245 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
246 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
247 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
248 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
249 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
250 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
251 |
+
"""
|
252 |
+
...
|
253 |
+
|
254 |
+
def like(self,
|
255 |
+
fn: Callable | None,
|
256 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
257 |
+
outputs: Component | Sequence[Component] | None = None,
|
258 |
+
api_name: str | None | Literal[False] = None,
|
259 |
+
status_tracker: None = None,
|
260 |
+
scroll_to_output: bool = False,
|
261 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
262 |
+
queue: bool | None = None,
|
263 |
+
batch: bool = False,
|
264 |
+
max_batch_size: int = 4,
|
265 |
+
preprocess: bool = True,
|
266 |
+
postprocess: bool = True,
|
267 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
268 |
+
every: float | None = None,
|
269 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
270 |
+
js: str | None = None,) -> Dependency:
|
271 |
+
"""
|
272 |
+
Parameters:
|
273 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
274 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
275 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
276 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
277 |
+
scroll_to_output: If True, will scroll to output component on completion
|
278 |
+
show_progress: If True, will show progress animation while pending
|
279 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
280 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
281 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
282 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
283 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
284 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
285 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
286 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
287 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
288 |
+
"""
|
289 |
+
...
|
src/backend/gradio_multimodalchatbot/templates/component/index.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/backend/gradio_multimodalchatbot/templates/component/style.css
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/demo/__init__.py
ADDED
File without changes
|
src/demo/app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_multimodalchatbot import MultimodalChatbot
|
4 |
+
from gradio.data_classes import FileData
|
5 |
+
|
6 |
+
user_msg1 = {"text": "Hello, what is in this image?",
|
7 |
+
"files": [{"file": FileData(path="https://gradio-builds.s3.amazonaws.com/diffusion_image/cute_dog.jpg")}]
|
8 |
+
}
|
9 |
+
bot_msg1 = {"text": "It is a very cute dog",
|
10 |
+
"files": []}
|
11 |
+
|
12 |
+
user_msg2 = {"text": "Describe this audio clip please.",
|
13 |
+
"files": [{"file": FileData(path="cantina.wav")}]}
|
14 |
+
bot_msg2 = {"text": "It is the cantina song from Star Wars",
|
15 |
+
"files": []}
|
16 |
+
|
17 |
+
user_msg3 = {"text": "Give me a video clip please.",
|
18 |
+
"files": []}
|
19 |
+
bot_msg3 = {"text": "Here is a video clip of the world",
|
20 |
+
"files": [{"file": FileData(path="world.mp4")},
|
21 |
+
{"file": FileData(path="cantina.wav")}]}
|
22 |
+
|
23 |
+
conversation = [[user_msg1, bot_msg1], [user_msg2, bot_msg2], [user_msg3, bot_msg3]]
|
24 |
+
|
25 |
+
with gr.Blocks() as demo:
|
26 |
+
MultimodalChatbot(value=conversation)
|
27 |
+
|
28 |
+
|
29 |
+
demo.launch()
|
src/demo/cantina.wav
ADDED
Binary file (132 kB). View file
|
|
src/demo/world.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:71944d7430c461f0cd6e7fd10cee7eb72786352a3678fc7bc0ae3d410f72aece
|
3 |
+
size 1570024
|
src/frontend/Index.svelte
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script context="module" lang="ts">
|
2 |
+
export { default as BaseChatBot } from "./shared/ChatBot.svelte";
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<script lang="ts">
|
6 |
+
import type { Gradio, SelectData, LikeData } from "@gradio/utils";
|
7 |
+
|
8 |
+
import ChatBot from "./shared/ChatBot.svelte";
|
9 |
+
import { Block, BlockLabel } from "@gradio/atoms";
|
10 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
11 |
+
import { Chat } from "@gradio/icons";
|
12 |
+
import { normalise_file, type FileData } from "@gradio/client";
|
13 |
+
import { StatusTracker } from "@gradio/statustracker";
|
14 |
+
import type { FileMessage, MultimodalMessage } from "./shared/utils";
|
15 |
+
|
16 |
+
export let elem_id = "";
|
17 |
+
export let elem_classes: string[] = [];
|
18 |
+
export let visible = true;
|
19 |
+
export let value: [
|
20 |
+
MultimodalMessage | null,
|
21 |
+
MultimodalMessage | null
|
22 |
+
][] = [];
|
23 |
+
export let scale: number | null = null;
|
24 |
+
export let min_width: number | undefined = undefined;
|
25 |
+
export let label: string;
|
26 |
+
export let show_label = true;
|
27 |
+
export let root: string;
|
28 |
+
export let proxy_url: null | string;
|
29 |
+
export let _selectable = false;
|
30 |
+
export let likeable = false;
|
31 |
+
export let show_share_button = false;
|
32 |
+
export let rtl = false;
|
33 |
+
export let show_copy_button = false;
|
34 |
+
export let sanitize_html = true;
|
35 |
+
export let bubble_full_width = true;
|
36 |
+
export let layout: "bubble" | "panel" = "bubble";
|
37 |
+
export let render_markdown = true;
|
38 |
+
export let line_breaks = true;
|
39 |
+
export let latex_delimiters: {
|
40 |
+
left: string;
|
41 |
+
right: string;
|
42 |
+
display: boolean;
|
43 |
+
}[];
|
44 |
+
export let gradio: Gradio<{
|
45 |
+
change: typeof value;
|
46 |
+
select: SelectData;
|
47 |
+
share: ShareData;
|
48 |
+
error: string;
|
49 |
+
like: LikeData;
|
50 |
+
}>;
|
51 |
+
export let avatar_images: [string | null, string | null] = [null, null];
|
52 |
+
|
53 |
+
let _value: [
|
54 |
+
MultimodalMessage | null,
|
55 |
+
MultimodalMessage | null
|
56 |
+
][];
|
57 |
+
|
58 |
+
const redirect_src_url = (src: string): string =>
|
59 |
+
src.replace('src="/file', `src="${root}file`);
|
60 |
+
|
61 |
+
function normalize_messages(
|
62 |
+
message: FileMessage | null
|
63 |
+
): FileMessage | null {
|
64 |
+
if (message === null) {
|
65 |
+
return message;
|
66 |
+
}
|
67 |
+
return {
|
68 |
+
file: normalise_file(message?.file, root, proxy_url) as FileData,
|
69 |
+
alt_text: message?.alt_text
|
70 |
+
};
|
71 |
+
}
|
72 |
+
|
73 |
+
function process_message(msg: MultimodalMessage | null): MultimodalMessage | null {
|
74 |
+
if (msg === null) {
|
75 |
+
return msg;
|
76 |
+
}
|
77 |
+
msg.text = redirect_src_url(msg.text);
|
78 |
+
msg.files = msg.files.map(normalize_messages);
|
79 |
+
return msg;
|
80 |
+
}
|
81 |
+
|
82 |
+
$: _value = value
|
83 |
+
? value.map(([user_msg, bot_msg]) => [
|
84 |
+
process_message(user_msg),
|
85 |
+
process_message(bot_msg)
|
86 |
+
])
|
87 |
+
: [];
|
88 |
+
|
89 |
+
export let loading_status: LoadingStatus | undefined = undefined;
|
90 |
+
export let height = 400;
|
91 |
+
</script>
|
92 |
+
|
93 |
+
<Block
|
94 |
+
{elem_id}
|
95 |
+
{elem_classes}
|
96 |
+
{visible}
|
97 |
+
padding={false}
|
98 |
+
{scale}
|
99 |
+
{min_width}
|
100 |
+
{height}
|
101 |
+
allow_overflow={false}
|
102 |
+
>
|
103 |
+
{#if loading_status}
|
104 |
+
<StatusTracker
|
105 |
+
autoscroll={gradio.autoscroll}
|
106 |
+
i18n={gradio.i18n}
|
107 |
+
{...loading_status}
|
108 |
+
show_progress={loading_status.show_progress === "hidden"
|
109 |
+
? "hidden"
|
110 |
+
: "minimal"}
|
111 |
+
/>
|
112 |
+
{/if}
|
113 |
+
<div class="wrapper">
|
114 |
+
{#if show_label}
|
115 |
+
<BlockLabel
|
116 |
+
{show_label}
|
117 |
+
Icon={Chat}
|
118 |
+
float={false}
|
119 |
+
label={label || "Chatbot"}
|
120 |
+
/>
|
121 |
+
{/if}
|
122 |
+
<ChatBot
|
123 |
+
i18n={gradio.i18n}
|
124 |
+
selectable={_selectable}
|
125 |
+
{likeable}
|
126 |
+
{show_share_button}
|
127 |
+
value={_value}
|
128 |
+
{latex_delimiters}
|
129 |
+
{render_markdown}
|
130 |
+
pending_message={loading_status?.status === "pending"}
|
131 |
+
{rtl}
|
132 |
+
{show_copy_button}
|
133 |
+
on:change={() => gradio.dispatch("change", value)}
|
134 |
+
on:select={(e) => gradio.dispatch("select", e.detail)}
|
135 |
+
on:like={(e) => gradio.dispatch("like", e.detail)}
|
136 |
+
on:share={(e) => gradio.dispatch("share", e.detail)}
|
137 |
+
on:error={(e) => gradio.dispatch("error", e.detail)}
|
138 |
+
{avatar_images}
|
139 |
+
{sanitize_html}
|
140 |
+
{bubble_full_width}
|
141 |
+
{line_breaks}
|
142 |
+
{layout}
|
143 |
+
{proxy_url}
|
144 |
+
{root}
|
145 |
+
/>
|
146 |
+
</div>
|
147 |
+
</Block>
|
148 |
+
|
149 |
+
<style>
|
150 |
+
.wrapper {
|
151 |
+
display: flex;
|
152 |
+
position: relative;
|
153 |
+
flex-direction: column;
|
154 |
+
align-items: start;
|
155 |
+
width: 100%;
|
156 |
+
height: 100%;
|
157 |
+
}
|
158 |
+
</style>
|
src/frontend/package-lock.json
ADDED
@@ -0,0 +1,1096 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_multimodalchatbot",
|
3 |
+
"version": "0.4.2",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "gradio_multimodalchatbot",
|
9 |
+
"version": "0.4.2",
|
10 |
+
"license": "ISC",
|
11 |
+
"dependencies": {
|
12 |
+
"@gradio/atoms": "0.2.0",
|
13 |
+
"@gradio/client": "0.7.1",
|
14 |
+
"@gradio/icons": "0.2.0",
|
15 |
+
"@gradio/markdown": "0.3.0",
|
16 |
+
"@gradio/statustracker": "0.3.0",
|
17 |
+
"@gradio/theme": "0.2.0",
|
18 |
+
"@gradio/upload": "0.3.2",
|
19 |
+
"@gradio/utils": "0.2.0",
|
20 |
+
"@types/dompurify": "^3.0.2",
|
21 |
+
"@types/katex": "^0.16.0",
|
22 |
+
"@types/prismjs": "1.26.1",
|
23 |
+
"dequal": "^2.0.2"
|
24 |
+
}
|
25 |
+
},
|
26 |
+
"node_modules/@ampproject/remapping": {
|
27 |
+
"version": "2.2.1",
|
28 |
+
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
|
29 |
+
"integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==",
|
30 |
+
"peer": true,
|
31 |
+
"dependencies": {
|
32 |
+
"@jridgewell/gen-mapping": "^0.3.0",
|
33 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
34 |
+
},
|
35 |
+
"engines": {
|
36 |
+
"node": ">=6.0.0"
|
37 |
+
}
|
38 |
+
},
|
39 |
+
"node_modules/@esbuild/android-arm": {
|
40 |
+
"version": "0.19.5",
|
41 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz",
|
42 |
+
"integrity": "sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==",
|
43 |
+
"cpu": [
|
44 |
+
"arm"
|
45 |
+
],
|
46 |
+
"optional": true,
|
47 |
+
"os": [
|
48 |
+
"android"
|
49 |
+
],
|
50 |
+
"engines": {
|
51 |
+
"node": ">=12"
|
52 |
+
}
|
53 |
+
},
|
54 |
+
"node_modules/@esbuild/android-arm64": {
|
55 |
+
"version": "0.19.5",
|
56 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.5.tgz",
|
57 |
+
"integrity": "sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==",
|
58 |
+
"cpu": [
|
59 |
+
"arm64"
|
60 |
+
],
|
61 |
+
"optional": true,
|
62 |
+
"os": [
|
63 |
+
"android"
|
64 |
+
],
|
65 |
+
"engines": {
|
66 |
+
"node": ">=12"
|
67 |
+
}
|
68 |
+
},
|
69 |
+
"node_modules/@esbuild/android-x64": {
|
70 |
+
"version": "0.19.5",
|
71 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.5.tgz",
|
72 |
+
"integrity": "sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==",
|
73 |
+
"cpu": [
|
74 |
+
"x64"
|
75 |
+
],
|
76 |
+
"optional": true,
|
77 |
+
"os": [
|
78 |
+
"android"
|
79 |
+
],
|
80 |
+
"engines": {
|
81 |
+
"node": ">=12"
|
82 |
+
}
|
83 |
+
},
|
84 |
+
"node_modules/@esbuild/darwin-arm64": {
|
85 |
+
"version": "0.19.5",
|
86 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.5.tgz",
|
87 |
+
"integrity": "sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==",
|
88 |
+
"cpu": [
|
89 |
+
"arm64"
|
90 |
+
],
|
91 |
+
"optional": true,
|
92 |
+
"os": [
|
93 |
+
"darwin"
|
94 |
+
],
|
95 |
+
"engines": {
|
96 |
+
"node": ">=12"
|
97 |
+
}
|
98 |
+
},
|
99 |
+
"node_modules/@esbuild/darwin-x64": {
|
100 |
+
"version": "0.19.5",
|
101 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.5.tgz",
|
102 |
+
"integrity": "sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==",
|
103 |
+
"cpu": [
|
104 |
+
"x64"
|
105 |
+
],
|
106 |
+
"optional": true,
|
107 |
+
"os": [
|
108 |
+
"darwin"
|
109 |
+
],
|
110 |
+
"engines": {
|
111 |
+
"node": ">=12"
|
112 |
+
}
|
113 |
+
},
|
114 |
+
"node_modules/@esbuild/freebsd-arm64": {
|
115 |
+
"version": "0.19.5",
|
116 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.5.tgz",
|
117 |
+
"integrity": "sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==",
|
118 |
+
"cpu": [
|
119 |
+
"arm64"
|
120 |
+
],
|
121 |
+
"optional": true,
|
122 |
+
"os": [
|
123 |
+
"freebsd"
|
124 |
+
],
|
125 |
+
"engines": {
|
126 |
+
"node": ">=12"
|
127 |
+
}
|
128 |
+
},
|
129 |
+
"node_modules/@esbuild/freebsd-x64": {
|
130 |
+
"version": "0.19.5",
|
131 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.5.tgz",
|
132 |
+
"integrity": "sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==",
|
133 |
+
"cpu": [
|
134 |
+
"x64"
|
135 |
+
],
|
136 |
+
"optional": true,
|
137 |
+
"os": [
|
138 |
+
"freebsd"
|
139 |
+
],
|
140 |
+
"engines": {
|
141 |
+
"node": ">=12"
|
142 |
+
}
|
143 |
+
},
|
144 |
+
"node_modules/@esbuild/linux-arm": {
|
145 |
+
"version": "0.19.5",
|
146 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.5.tgz",
|
147 |
+
"integrity": "sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==",
|
148 |
+
"cpu": [
|
149 |
+
"arm"
|
150 |
+
],
|
151 |
+
"optional": true,
|
152 |
+
"os": [
|
153 |
+
"linux"
|
154 |
+
],
|
155 |
+
"engines": {
|
156 |
+
"node": ">=12"
|
157 |
+
}
|
158 |
+
},
|
159 |
+
"node_modules/@esbuild/linux-arm64": {
|
160 |
+
"version": "0.19.5",
|
161 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.5.tgz",
|
162 |
+
"integrity": "sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==",
|
163 |
+
"cpu": [
|
164 |
+
"arm64"
|
165 |
+
],
|
166 |
+
"optional": true,
|
167 |
+
"os": [
|
168 |
+
"linux"
|
169 |
+
],
|
170 |
+
"engines": {
|
171 |
+
"node": ">=12"
|
172 |
+
}
|
173 |
+
},
|
174 |
+
"node_modules/@esbuild/linux-ia32": {
|
175 |
+
"version": "0.19.5",
|
176 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.5.tgz",
|
177 |
+
"integrity": "sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==",
|
178 |
+
"cpu": [
|
179 |
+
"ia32"
|
180 |
+
],
|
181 |
+
"optional": true,
|
182 |
+
"os": [
|
183 |
+
"linux"
|
184 |
+
],
|
185 |
+
"engines": {
|
186 |
+
"node": ">=12"
|
187 |
+
}
|
188 |
+
},
|
189 |
+
"node_modules/@esbuild/linux-loong64": {
|
190 |
+
"version": "0.19.5",
|
191 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.5.tgz",
|
192 |
+
"integrity": "sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==",
|
193 |
+
"cpu": [
|
194 |
+
"loong64"
|
195 |
+
],
|
196 |
+
"optional": true,
|
197 |
+
"os": [
|
198 |
+
"linux"
|
199 |
+
],
|
200 |
+
"engines": {
|
201 |
+
"node": ">=12"
|
202 |
+
}
|
203 |
+
},
|
204 |
+
"node_modules/@esbuild/linux-mips64el": {
|
205 |
+
"version": "0.19.5",
|
206 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.5.tgz",
|
207 |
+
"integrity": "sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==",
|
208 |
+
"cpu": [
|
209 |
+
"mips64el"
|
210 |
+
],
|
211 |
+
"optional": true,
|
212 |
+
"os": [
|
213 |
+
"linux"
|
214 |
+
],
|
215 |
+
"engines": {
|
216 |
+
"node": ">=12"
|
217 |
+
}
|
218 |
+
},
|
219 |
+
"node_modules/@esbuild/linux-ppc64": {
|
220 |
+
"version": "0.19.5",
|
221 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.5.tgz",
|
222 |
+
"integrity": "sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==",
|
223 |
+
"cpu": [
|
224 |
+
"ppc64"
|
225 |
+
],
|
226 |
+
"optional": true,
|
227 |
+
"os": [
|
228 |
+
"linux"
|
229 |
+
],
|
230 |
+
"engines": {
|
231 |
+
"node": ">=12"
|
232 |
+
}
|
233 |
+
},
|
234 |
+
"node_modules/@esbuild/linux-riscv64": {
|
235 |
+
"version": "0.19.5",
|
236 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.5.tgz",
|
237 |
+
"integrity": "sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==",
|
238 |
+
"cpu": [
|
239 |
+
"riscv64"
|
240 |
+
],
|
241 |
+
"optional": true,
|
242 |
+
"os": [
|
243 |
+
"linux"
|
244 |
+
],
|
245 |
+
"engines": {
|
246 |
+
"node": ">=12"
|
247 |
+
}
|
248 |
+
},
|
249 |
+
"node_modules/@esbuild/linux-s390x": {
|
250 |
+
"version": "0.19.5",
|
251 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.5.tgz",
|
252 |
+
"integrity": "sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==",
|
253 |
+
"cpu": [
|
254 |
+
"s390x"
|
255 |
+
],
|
256 |
+
"optional": true,
|
257 |
+
"os": [
|
258 |
+
"linux"
|
259 |
+
],
|
260 |
+
"engines": {
|
261 |
+
"node": ">=12"
|
262 |
+
}
|
263 |
+
},
|
264 |
+
"node_modules/@esbuild/linux-x64": {
|
265 |
+
"version": "0.19.5",
|
266 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.5.tgz",
|
267 |
+
"integrity": "sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==",
|
268 |
+
"cpu": [
|
269 |
+
"x64"
|
270 |
+
],
|
271 |
+
"optional": true,
|
272 |
+
"os": [
|
273 |
+
"linux"
|
274 |
+
],
|
275 |
+
"engines": {
|
276 |
+
"node": ">=12"
|
277 |
+
}
|
278 |
+
},
|
279 |
+
"node_modules/@esbuild/netbsd-x64": {
|
280 |
+
"version": "0.19.5",
|
281 |
+
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.5.tgz",
|
282 |
+
"integrity": "sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==",
|
283 |
+
"cpu": [
|
284 |
+
"x64"
|
285 |
+
],
|
286 |
+
"optional": true,
|
287 |
+
"os": [
|
288 |
+
"netbsd"
|
289 |
+
],
|
290 |
+
"engines": {
|
291 |
+
"node": ">=12"
|
292 |
+
}
|
293 |
+
},
|
294 |
+
"node_modules/@esbuild/openbsd-x64": {
|
295 |
+
"version": "0.19.5",
|
296 |
+
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz",
|
297 |
+
"integrity": "sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==",
|
298 |
+
"cpu": [
|
299 |
+
"x64"
|
300 |
+
],
|
301 |
+
"optional": true,
|
302 |
+
"os": [
|
303 |
+
"openbsd"
|
304 |
+
],
|
305 |
+
"engines": {
|
306 |
+
"node": ">=12"
|
307 |
+
}
|
308 |
+
},
|
309 |
+
"node_modules/@esbuild/sunos-x64": {
|
310 |
+
"version": "0.19.5",
|
311 |
+
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.5.tgz",
|
312 |
+
"integrity": "sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==",
|
313 |
+
"cpu": [
|
314 |
+
"x64"
|
315 |
+
],
|
316 |
+
"optional": true,
|
317 |
+
"os": [
|
318 |
+
"sunos"
|
319 |
+
],
|
320 |
+
"engines": {
|
321 |
+
"node": ">=12"
|
322 |
+
}
|
323 |
+
},
|
324 |
+
"node_modules/@esbuild/win32-arm64": {
|
325 |
+
"version": "0.19.5",
|
326 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.5.tgz",
|
327 |
+
"integrity": "sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==",
|
328 |
+
"cpu": [
|
329 |
+
"arm64"
|
330 |
+
],
|
331 |
+
"optional": true,
|
332 |
+
"os": [
|
333 |
+
"win32"
|
334 |
+
],
|
335 |
+
"engines": {
|
336 |
+
"node": ">=12"
|
337 |
+
}
|
338 |
+
},
|
339 |
+
"node_modules/@esbuild/win32-ia32": {
|
340 |
+
"version": "0.19.5",
|
341 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.5.tgz",
|
342 |
+
"integrity": "sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==",
|
343 |
+
"cpu": [
|
344 |
+
"ia32"
|
345 |
+
],
|
346 |
+
"optional": true,
|
347 |
+
"os": [
|
348 |
+
"win32"
|
349 |
+
],
|
350 |
+
"engines": {
|
351 |
+
"node": ">=12"
|
352 |
+
}
|
353 |
+
},
|
354 |
+
"node_modules/@esbuild/win32-x64": {
|
355 |
+
"version": "0.19.5",
|
356 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.5.tgz",
|
357 |
+
"integrity": "sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==",
|
358 |
+
"cpu": [
|
359 |
+
"x64"
|
360 |
+
],
|
361 |
+
"optional": true,
|
362 |
+
"os": [
|
363 |
+
"win32"
|
364 |
+
],
|
365 |
+
"engines": {
|
366 |
+
"node": ">=12"
|
367 |
+
}
|
368 |
+
},
|
369 |
+
"node_modules/@formatjs/ecma402-abstract": {
|
370 |
+
"version": "1.11.4",
|
371 |
+
"resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
|
372 |
+
"integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
|
373 |
+
"dependencies": {
|
374 |
+
"@formatjs/intl-localematcher": "0.2.25",
|
375 |
+
"tslib": "^2.1.0"
|
376 |
+
}
|
377 |
+
},
|
378 |
+
"node_modules/@formatjs/fast-memoize": {
|
379 |
+
"version": "1.2.1",
|
380 |
+
"resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
|
381 |
+
"integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
|
382 |
+
"dependencies": {
|
383 |
+
"tslib": "^2.1.0"
|
384 |
+
}
|
385 |
+
},
|
386 |
+
"node_modules/@formatjs/icu-messageformat-parser": {
|
387 |
+
"version": "2.1.0",
|
388 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
|
389 |
+
"integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
|
390 |
+
"dependencies": {
|
391 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
392 |
+
"@formatjs/icu-skeleton-parser": "1.3.6",
|
393 |
+
"tslib": "^2.1.0"
|
394 |
+
}
|
395 |
+
},
|
396 |
+
"node_modules/@formatjs/icu-skeleton-parser": {
|
397 |
+
"version": "1.3.6",
|
398 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
|
399 |
+
"integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
|
400 |
+
"dependencies": {
|
401 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
402 |
+
"tslib": "^2.1.0"
|
403 |
+
}
|
404 |
+
},
|
405 |
+
"node_modules/@formatjs/intl-localematcher": {
|
406 |
+
"version": "0.2.25",
|
407 |
+
"resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
|
408 |
+
"integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
|
409 |
+
"dependencies": {
|
410 |
+
"tslib": "^2.1.0"
|
411 |
+
}
|
412 |
+
},
|
413 |
+
"node_modules/@gradio/atoms": {
|
414 |
+
"version": "0.2.0",
|
415 |
+
"resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.2.0.tgz",
|
416 |
+
"integrity": "sha512-7pTXJTZv+KECtTG9vqeq9j7vz5OKkp+TRvh+O4yMbtkvxFEbhYaaUngkWFX26btGiveD+V4RG4qrP17jqpSdGA==",
|
417 |
+
"dependencies": {
|
418 |
+
"@gradio/icons": "^0.2.0",
|
419 |
+
"@gradio/utils": "^0.2.0"
|
420 |
+
}
|
421 |
+
},
|
422 |
+
"node_modules/@gradio/client": {
|
423 |
+
"version": "0.7.1",
|
424 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.7.1.tgz",
|
425 |
+
"integrity": "sha512-capRFmuk0EDI7oIGmRiSGZwcvsXEO9qnwUHBcSmawXPTPnuuZlBOMVERancuO8RO8PtUAozTgBCaLXP9TFhypQ==",
|
426 |
+
"dependencies": {
|
427 |
+
"bufferutil": "^4.0.7",
|
428 |
+
"semiver": "^1.1.0",
|
429 |
+
"ws": "^8.13.0"
|
430 |
+
},
|
431 |
+
"engines": {
|
432 |
+
"node": ">=18.0.0"
|
433 |
+
}
|
434 |
+
},
|
435 |
+
"node_modules/@gradio/column": {
|
436 |
+
"version": "0.1.0",
|
437 |
+
"resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
|
438 |
+
"integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
|
439 |
+
},
|
440 |
+
"node_modules/@gradio/icons": {
|
441 |
+
"version": "0.2.0",
|
442 |
+
"resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.2.0.tgz",
|
443 |
+
"integrity": "sha512-rfCSmOF+ALqBOjTWL1ICasyA8JuO0MPwFrtlVMyAWp7R14AN8YChC/gbz5fZ0kNBiGGEYOOfqpKxyvC95jGGlg=="
|
444 |
+
},
|
445 |
+
"node_modules/@gradio/markdown": {
|
446 |
+
"version": "0.3.0",
|
447 |
+
"resolved": "https://registry.npmjs.org/@gradio/markdown/-/markdown-0.3.0.tgz",
|
448 |
+
"integrity": "sha512-UNGI3Ji6j4cQw52C3a1g7lHs2wwMr68AMcd8UpJ6xWi4aAKalrqKNsgZQnV07zmHY04UzZh60f36uBsAI/34ow==",
|
449 |
+
"dependencies": {
|
450 |
+
"@gradio/atoms": "^0.2.0",
|
451 |
+
"@gradio/statustracker": "^0.3.0",
|
452 |
+
"@gradio/utils": "^0.2.0",
|
453 |
+
"@types/dompurify": "^3.0.2",
|
454 |
+
"@types/katex": "^0.16.0",
|
455 |
+
"@types/prismjs": "1.26.1",
|
456 |
+
"dompurify": "^3.0.3",
|
457 |
+
"katex": "^0.16.7",
|
458 |
+
"marked": "^7.0.0",
|
459 |
+
"marked-highlight": "^2.0.1",
|
460 |
+
"prismjs": "1.29.0"
|
461 |
+
}
|
462 |
+
},
|
463 |
+
"node_modules/@gradio/statustracker": {
|
464 |
+
"version": "0.3.0",
|
465 |
+
"resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.3.0.tgz",
|
466 |
+
"integrity": "sha512-8F3ezqPoGpq7B0EFYGVJkiYOrXCJLMEBcjLTOk2NeM2tXUoOCTieSvJEOstLzM0KkHwY7FvVrc3Dn5iqfIq2lQ==",
|
467 |
+
"dependencies": {
|
468 |
+
"@gradio/atoms": "^0.2.0",
|
469 |
+
"@gradio/column": "^0.1.0",
|
470 |
+
"@gradio/icons": "^0.2.0",
|
471 |
+
"@gradio/utils": "^0.2.0"
|
472 |
+
}
|
473 |
+
},
|
474 |
+
"node_modules/@gradio/theme": {
|
475 |
+
"version": "0.2.0",
|
476 |
+
"resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.0.tgz",
|
477 |
+
"integrity": "sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ=="
|
478 |
+
},
|
479 |
+
"node_modules/@gradio/upload": {
|
480 |
+
"version": "0.3.2",
|
481 |
+
"resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.3.2.tgz",
|
482 |
+
"integrity": "sha512-Yc5w8VZxLOVYhH1Kd3QsSUQM2SoKLom7tOn/xgY09/GnR47/AaEwPINJEHnm3DsV8FYj/dd5ggSEGTEBbR3Q2g==",
|
483 |
+
"dependencies": {
|
484 |
+
"@gradio/atoms": "^0.2.0",
|
485 |
+
"@gradio/client": "^0.7.1",
|
486 |
+
"@gradio/icons": "^0.2.0",
|
487 |
+
"@gradio/upload": "^0.3.2",
|
488 |
+
"@gradio/utils": "^0.2.0"
|
489 |
+
}
|
490 |
+
},
|
491 |
+
"node_modules/@gradio/utils": {
|
492 |
+
"version": "0.2.0",
|
493 |
+
"resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.2.0.tgz",
|
494 |
+
"integrity": "sha512-YkwzXufi6IxQrlMW+1sFo8Yn6F9NLL69ZoBsbo7QEhms0v5L7pmOTw+dfd7M3dwbRP2lgjrb52i1kAIN3n6aqQ==",
|
495 |
+
"dependencies": {
|
496 |
+
"@gradio/theme": "^0.2.0",
|
497 |
+
"svelte-i18n": "^3.6.0"
|
498 |
+
}
|
499 |
+
},
|
500 |
+
"node_modules/@jridgewell/gen-mapping": {
|
501 |
+
"version": "0.3.3",
|
502 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz",
|
503 |
+
"integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==",
|
504 |
+
"peer": true,
|
505 |
+
"dependencies": {
|
506 |
+
"@jridgewell/set-array": "^1.0.1",
|
507 |
+
"@jridgewell/sourcemap-codec": "^1.4.10",
|
508 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
509 |
+
},
|
510 |
+
"engines": {
|
511 |
+
"node": ">=6.0.0"
|
512 |
+
}
|
513 |
+
},
|
514 |
+
"node_modules/@jridgewell/resolve-uri": {
|
515 |
+
"version": "3.1.1",
|
516 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
|
517 |
+
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
|
518 |
+
"peer": true,
|
519 |
+
"engines": {
|
520 |
+
"node": ">=6.0.0"
|
521 |
+
}
|
522 |
+
},
|
523 |
+
"node_modules/@jridgewell/set-array": {
|
524 |
+
"version": "1.1.2",
|
525 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
|
526 |
+
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
|
527 |
+
"peer": true,
|
528 |
+
"engines": {
|
529 |
+
"node": ">=6.0.0"
|
530 |
+
}
|
531 |
+
},
|
532 |
+
"node_modules/@jridgewell/sourcemap-codec": {
|
533 |
+
"version": "1.4.15",
|
534 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
|
535 |
+
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
|
536 |
+
"peer": true
|
537 |
+
},
|
538 |
+
"node_modules/@jridgewell/trace-mapping": {
|
539 |
+
"version": "0.3.20",
|
540 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz",
|
541 |
+
"integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==",
|
542 |
+
"peer": true,
|
543 |
+
"dependencies": {
|
544 |
+
"@jridgewell/resolve-uri": "^3.1.0",
|
545 |
+
"@jridgewell/sourcemap-codec": "^1.4.14"
|
546 |
+
}
|
547 |
+
},
|
548 |
+
"node_modules/@types/dompurify": {
|
549 |
+
"version": "3.0.5",
|
550 |
+
"resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.5.tgz",
|
551 |
+
"integrity": "sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==",
|
552 |
+
"dependencies": {
|
553 |
+
"@types/trusted-types": "*"
|
554 |
+
}
|
555 |
+
},
|
556 |
+
"node_modules/@types/estree": {
|
557 |
+
"version": "1.0.5",
|
558 |
+
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
559 |
+
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
560 |
+
"peer": true
|
561 |
+
},
|
562 |
+
"node_modules/@types/katex": {
|
563 |
+
"version": "0.16.6",
|
564 |
+
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.6.tgz",
|
565 |
+
"integrity": "sha512-rZYO1HInM99rAFYNwGqbYPxHZHxu2IwZYKj4bJ4oh6edVrm1UId8mmbHIZLBtG253qU6y3piag0XYe/joNnwzQ=="
|
566 |
+
},
|
567 |
+
"node_modules/@types/prismjs": {
|
568 |
+
"version": "1.26.1",
|
569 |
+
"resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.1.tgz",
|
570 |
+
"integrity": "sha512-Q7jDsRbzcNHIQje15CS/piKhu6lMLb9jwjxSfEIi4KcFKXW23GoJMkwQiJ8VObyfx+VmUaDcJxXaWN+cTCjVog=="
|
571 |
+
},
|
572 |
+
"node_modules/@types/trusted-types": {
|
573 |
+
"version": "2.0.6",
|
574 |
+
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.6.tgz",
|
575 |
+
"integrity": "sha512-HYtNooPvUY9WAVRBr4u+4Qa9fYD1ze2IUlAD3HoA6oehn1taGwBx3Oa52U4mTslTS+GAExKpaFu39Y5xUEwfjg=="
|
576 |
+
},
|
577 |
+
"node_modules/acorn": {
|
578 |
+
"version": "8.11.2",
|
579 |
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
|
580 |
+
"integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
|
581 |
+
"peer": true,
|
582 |
+
"bin": {
|
583 |
+
"acorn": "bin/acorn"
|
584 |
+
},
|
585 |
+
"engines": {
|
586 |
+
"node": ">=0.4.0"
|
587 |
+
}
|
588 |
+
},
|
589 |
+
"node_modules/aria-query": {
|
590 |
+
"version": "5.3.0",
|
591 |
+
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
|
592 |
+
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
|
593 |
+
"peer": true,
|
594 |
+
"dependencies": {
|
595 |
+
"dequal": "^2.0.3"
|
596 |
+
}
|
597 |
+
},
|
598 |
+
"node_modules/axobject-query": {
|
599 |
+
"version": "3.2.1",
|
600 |
+
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
|
601 |
+
"integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==",
|
602 |
+
"peer": true,
|
603 |
+
"dependencies": {
|
604 |
+
"dequal": "^2.0.3"
|
605 |
+
}
|
606 |
+
},
|
607 |
+
"node_modules/bufferutil": {
|
608 |
+
"version": "4.0.8",
|
609 |
+
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz",
|
610 |
+
"integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==",
|
611 |
+
"hasInstallScript": true,
|
612 |
+
"dependencies": {
|
613 |
+
"node-gyp-build": "^4.3.0"
|
614 |
+
},
|
615 |
+
"engines": {
|
616 |
+
"node": ">=6.14.2"
|
617 |
+
}
|
618 |
+
},
|
619 |
+
"node_modules/cli-color": {
|
620 |
+
"version": "2.0.3",
|
621 |
+
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz",
|
622 |
+
"integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==",
|
623 |
+
"dependencies": {
|
624 |
+
"d": "^1.0.1",
|
625 |
+
"es5-ext": "^0.10.61",
|
626 |
+
"es6-iterator": "^2.0.3",
|
627 |
+
"memoizee": "^0.4.15",
|
628 |
+
"timers-ext": "^0.1.7"
|
629 |
+
},
|
630 |
+
"engines": {
|
631 |
+
"node": ">=0.10"
|
632 |
+
}
|
633 |
+
},
|
634 |
+
"node_modules/code-red": {
|
635 |
+
"version": "1.0.4",
|
636 |
+
"resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
|
637 |
+
"integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
|
638 |
+
"peer": true,
|
639 |
+
"dependencies": {
|
640 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
641 |
+
"@types/estree": "^1.0.1",
|
642 |
+
"acorn": "^8.10.0",
|
643 |
+
"estree-walker": "^3.0.3",
|
644 |
+
"periscopic": "^3.1.0"
|
645 |
+
}
|
646 |
+
},
|
647 |
+
"node_modules/commander": {
|
648 |
+
"version": "8.3.0",
|
649 |
+
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
|
650 |
+
"integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
|
651 |
+
"engines": {
|
652 |
+
"node": ">= 12"
|
653 |
+
}
|
654 |
+
},
|
655 |
+
"node_modules/css-tree": {
|
656 |
+
"version": "2.3.1",
|
657 |
+
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
|
658 |
+
"integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
|
659 |
+
"peer": true,
|
660 |
+
"dependencies": {
|
661 |
+
"mdn-data": "2.0.30",
|
662 |
+
"source-map-js": "^1.0.1"
|
663 |
+
},
|
664 |
+
"engines": {
|
665 |
+
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
|
666 |
+
}
|
667 |
+
},
|
668 |
+
"node_modules/d": {
|
669 |
+
"version": "1.0.1",
|
670 |
+
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
671 |
+
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
672 |
+
"dependencies": {
|
673 |
+
"es5-ext": "^0.10.50",
|
674 |
+
"type": "^1.0.1"
|
675 |
+
}
|
676 |
+
},
|
677 |
+
"node_modules/deepmerge": {
|
678 |
+
"version": "4.3.1",
|
679 |
+
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
680 |
+
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
681 |
+
"engines": {
|
682 |
+
"node": ">=0.10.0"
|
683 |
+
}
|
684 |
+
},
|
685 |
+
"node_modules/dequal": {
|
686 |
+
"version": "2.0.3",
|
687 |
+
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
|
688 |
+
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
|
689 |
+
"engines": {
|
690 |
+
"node": ">=6"
|
691 |
+
}
|
692 |
+
},
|
693 |
+
"node_modules/dompurify": {
|
694 |
+
"version": "3.0.6",
|
695 |
+
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.6.tgz",
|
696 |
+
"integrity": "sha512-ilkD8YEnnGh1zJ240uJsW7AzE+2qpbOUYjacomn3AvJ6J4JhKGSZ2nh4wUIXPZrEPppaCLx5jFe8T89Rk8tQ7w=="
|
697 |
+
},
|
698 |
+
"node_modules/es5-ext": {
|
699 |
+
"version": "0.10.62",
|
700 |
+
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
701 |
+
"integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
|
702 |
+
"hasInstallScript": true,
|
703 |
+
"dependencies": {
|
704 |
+
"es6-iterator": "^2.0.3",
|
705 |
+
"es6-symbol": "^3.1.3",
|
706 |
+
"next-tick": "^1.1.0"
|
707 |
+
},
|
708 |
+
"engines": {
|
709 |
+
"node": ">=0.10"
|
710 |
+
}
|
711 |
+
},
|
712 |
+
"node_modules/es6-iterator": {
|
713 |
+
"version": "2.0.3",
|
714 |
+
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
715 |
+
"integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
|
716 |
+
"dependencies": {
|
717 |
+
"d": "1",
|
718 |
+
"es5-ext": "^0.10.35",
|
719 |
+
"es6-symbol": "^3.1.1"
|
720 |
+
}
|
721 |
+
},
|
722 |
+
"node_modules/es6-symbol": {
|
723 |
+
"version": "3.1.3",
|
724 |
+
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
725 |
+
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
726 |
+
"dependencies": {
|
727 |
+
"d": "^1.0.1",
|
728 |
+
"ext": "^1.1.2"
|
729 |
+
}
|
730 |
+
},
|
731 |
+
"node_modules/es6-weak-map": {
|
732 |
+
"version": "2.0.3",
|
733 |
+
"resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
|
734 |
+
"integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
|
735 |
+
"dependencies": {
|
736 |
+
"d": "1",
|
737 |
+
"es5-ext": "^0.10.46",
|
738 |
+
"es6-iterator": "^2.0.3",
|
739 |
+
"es6-symbol": "^3.1.1"
|
740 |
+
}
|
741 |
+
},
|
742 |
+
"node_modules/esbuild": {
|
743 |
+
"version": "0.19.5",
|
744 |
+
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz",
|
745 |
+
"integrity": "sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==",
|
746 |
+
"hasInstallScript": true,
|
747 |
+
"bin": {
|
748 |
+
"esbuild": "bin/esbuild"
|
749 |
+
},
|
750 |
+
"engines": {
|
751 |
+
"node": ">=12"
|
752 |
+
},
|
753 |
+
"optionalDependencies": {
|
754 |
+
"@esbuild/android-arm": "0.19.5",
|
755 |
+
"@esbuild/android-arm64": "0.19.5",
|
756 |
+
"@esbuild/android-x64": "0.19.5",
|
757 |
+
"@esbuild/darwin-arm64": "0.19.5",
|
758 |
+
"@esbuild/darwin-x64": "0.19.5",
|
759 |
+
"@esbuild/freebsd-arm64": "0.19.5",
|
760 |
+
"@esbuild/freebsd-x64": "0.19.5",
|
761 |
+
"@esbuild/linux-arm": "0.19.5",
|
762 |
+
"@esbuild/linux-arm64": "0.19.5",
|
763 |
+
"@esbuild/linux-ia32": "0.19.5",
|
764 |
+
"@esbuild/linux-loong64": "0.19.5",
|
765 |
+
"@esbuild/linux-mips64el": "0.19.5",
|
766 |
+
"@esbuild/linux-ppc64": "0.19.5",
|
767 |
+
"@esbuild/linux-riscv64": "0.19.5",
|
768 |
+
"@esbuild/linux-s390x": "0.19.5",
|
769 |
+
"@esbuild/linux-x64": "0.19.5",
|
770 |
+
"@esbuild/netbsd-x64": "0.19.5",
|
771 |
+
"@esbuild/openbsd-x64": "0.19.5",
|
772 |
+
"@esbuild/sunos-x64": "0.19.5",
|
773 |
+
"@esbuild/win32-arm64": "0.19.5",
|
774 |
+
"@esbuild/win32-ia32": "0.19.5",
|
775 |
+
"@esbuild/win32-x64": "0.19.5"
|
776 |
+
}
|
777 |
+
},
|
778 |
+
"node_modules/estree-walker": {
|
779 |
+
"version": "3.0.3",
|
780 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
781 |
+
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
782 |
+
"peer": true,
|
783 |
+
"dependencies": {
|
784 |
+
"@types/estree": "^1.0.0"
|
785 |
+
}
|
786 |
+
},
|
787 |
+
"node_modules/event-emitter": {
|
788 |
+
"version": "0.3.5",
|
789 |
+
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
790 |
+
"integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
|
791 |
+
"dependencies": {
|
792 |
+
"d": "1",
|
793 |
+
"es5-ext": "~0.10.14"
|
794 |
+
}
|
795 |
+
},
|
796 |
+
"node_modules/ext": {
|
797 |
+
"version": "1.7.0",
|
798 |
+
"resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
|
799 |
+
"integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
|
800 |
+
"dependencies": {
|
801 |
+
"type": "^2.7.2"
|
802 |
+
}
|
803 |
+
},
|
804 |
+
"node_modules/ext/node_modules/type": {
|
805 |
+
"version": "2.7.2",
|
806 |
+
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
807 |
+
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
808 |
+
},
|
809 |
+
"node_modules/globalyzer": {
|
810 |
+
"version": "0.1.0",
|
811 |
+
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
|
812 |
+
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
|
813 |
+
},
|
814 |
+
"node_modules/globrex": {
|
815 |
+
"version": "0.1.2",
|
816 |
+
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
|
817 |
+
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
|
818 |
+
},
|
819 |
+
"node_modules/intl-messageformat": {
|
820 |
+
"version": "9.13.0",
|
821 |
+
"resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
|
822 |
+
"integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
|
823 |
+
"dependencies": {
|
824 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
825 |
+
"@formatjs/fast-memoize": "1.2.1",
|
826 |
+
"@formatjs/icu-messageformat-parser": "2.1.0",
|
827 |
+
"tslib": "^2.1.0"
|
828 |
+
}
|
829 |
+
},
|
830 |
+
"node_modules/is-promise": {
|
831 |
+
"version": "2.2.2",
|
832 |
+
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
833 |
+
"integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
|
834 |
+
},
|
835 |
+
"node_modules/is-reference": {
|
836 |
+
"version": "3.0.2",
|
837 |
+
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
|
838 |
+
"integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
|
839 |
+
"peer": true,
|
840 |
+
"dependencies": {
|
841 |
+
"@types/estree": "*"
|
842 |
+
}
|
843 |
+
},
|
844 |
+
"node_modules/katex": {
|
845 |
+
"version": "0.16.9",
|
846 |
+
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.9.tgz",
|
847 |
+
"integrity": "sha512-fsSYjWS0EEOwvy81j3vRA8TEAhQhKiqO+FQaKWp0m39qwOzHVBgAUBIXWj1pB+O2W3fIpNa6Y9KSKCVbfPhyAQ==",
|
848 |
+
"funding": [
|
849 |
+
"https://opencollective.com/katex",
|
850 |
+
"https://github.com/sponsors/katex"
|
851 |
+
],
|
852 |
+
"dependencies": {
|
853 |
+
"commander": "^8.3.0"
|
854 |
+
},
|
855 |
+
"bin": {
|
856 |
+
"katex": "cli.js"
|
857 |
+
}
|
858 |
+
},
|
859 |
+
"node_modules/locate-character": {
|
860 |
+
"version": "3.0.0",
|
861 |
+
"resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
|
862 |
+
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
863 |
+
"peer": true
|
864 |
+
},
|
865 |
+
"node_modules/lru-queue": {
|
866 |
+
"version": "0.1.0",
|
867 |
+
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
868 |
+
"integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
|
869 |
+
"dependencies": {
|
870 |
+
"es5-ext": "~0.10.2"
|
871 |
+
}
|
872 |
+
},
|
873 |
+
"node_modules/magic-string": {
|
874 |
+
"version": "0.30.5",
|
875 |
+
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
|
876 |
+
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
|
877 |
+
"peer": true,
|
878 |
+
"dependencies": {
|
879 |
+
"@jridgewell/sourcemap-codec": "^1.4.15"
|
880 |
+
},
|
881 |
+
"engines": {
|
882 |
+
"node": ">=12"
|
883 |
+
}
|
884 |
+
},
|
885 |
+
"node_modules/marked": {
|
886 |
+
"version": "7.0.5",
|
887 |
+
"resolved": "https://registry.npmjs.org/marked/-/marked-7.0.5.tgz",
|
888 |
+
"integrity": "sha512-lwNAFTfXgqpt/XvK17a/8wY9/q6fcSPZT1aP6QW0u74VwaJF/Z9KbRcX23sWE4tODM+AolJNcUtErTkgOeFP/Q==",
|
889 |
+
"bin": {
|
890 |
+
"marked": "bin/marked.js"
|
891 |
+
},
|
892 |
+
"engines": {
|
893 |
+
"node": ">= 16"
|
894 |
+
}
|
895 |
+
},
|
896 |
+
"node_modules/marked-highlight": {
|
897 |
+
"version": "2.0.6",
|
898 |
+
"resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.0.6.tgz",
|
899 |
+
"integrity": "sha512-xjA/C6xgXAfkkYg+YHnxdjmgFyTDtqqu8KbZiqh+COJ7PuzR15kqa+rPrs6pf/2jExXtG1jyCFUHmv9s0Bi/dQ==",
|
900 |
+
"peerDependencies": {
|
901 |
+
"marked": ">=4 <10"
|
902 |
+
}
|
903 |
+
},
|
904 |
+
"node_modules/mdn-data": {
|
905 |
+
"version": "2.0.30",
|
906 |
+
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
|
907 |
+
"integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
|
908 |
+
"peer": true
|
909 |
+
},
|
910 |
+
"node_modules/memoizee": {
|
911 |
+
"version": "0.4.15",
|
912 |
+
"resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
|
913 |
+
"integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
|
914 |
+
"dependencies": {
|
915 |
+
"d": "^1.0.1",
|
916 |
+
"es5-ext": "^0.10.53",
|
917 |
+
"es6-weak-map": "^2.0.3",
|
918 |
+
"event-emitter": "^0.3.5",
|
919 |
+
"is-promise": "^2.2.2",
|
920 |
+
"lru-queue": "^0.1.0",
|
921 |
+
"next-tick": "^1.1.0",
|
922 |
+
"timers-ext": "^0.1.7"
|
923 |
+
}
|
924 |
+
},
|
925 |
+
"node_modules/mri": {
|
926 |
+
"version": "1.2.0",
|
927 |
+
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
928 |
+
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
929 |
+
"engines": {
|
930 |
+
"node": ">=4"
|
931 |
+
}
|
932 |
+
},
|
933 |
+
"node_modules/next-tick": {
|
934 |
+
"version": "1.1.0",
|
935 |
+
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
936 |
+
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
937 |
+
},
|
938 |
+
"node_modules/node-gyp-build": {
|
939 |
+
"version": "4.6.1",
|
940 |
+
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz",
|
941 |
+
"integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==",
|
942 |
+
"bin": {
|
943 |
+
"node-gyp-build": "bin.js",
|
944 |
+
"node-gyp-build-optional": "optional.js",
|
945 |
+
"node-gyp-build-test": "build-test.js"
|
946 |
+
}
|
947 |
+
},
|
948 |
+
"node_modules/periscopic": {
|
949 |
+
"version": "3.1.0",
|
950 |
+
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
|
951 |
+
"integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
|
952 |
+
"peer": true,
|
953 |
+
"dependencies": {
|
954 |
+
"@types/estree": "^1.0.0",
|
955 |
+
"estree-walker": "^3.0.0",
|
956 |
+
"is-reference": "^3.0.0"
|
957 |
+
}
|
958 |
+
},
|
959 |
+
"node_modules/prismjs": {
|
960 |
+
"version": "1.29.0",
|
961 |
+
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
|
962 |
+
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
|
963 |
+
"engines": {
|
964 |
+
"node": ">=6"
|
965 |
+
}
|
966 |
+
},
|
967 |
+
"node_modules/sade": {
|
968 |
+
"version": "1.8.1",
|
969 |
+
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
|
970 |
+
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
|
971 |
+
"dependencies": {
|
972 |
+
"mri": "^1.1.0"
|
973 |
+
},
|
974 |
+
"engines": {
|
975 |
+
"node": ">=6"
|
976 |
+
}
|
977 |
+
},
|
978 |
+
"node_modules/semiver": {
|
979 |
+
"version": "1.1.0",
|
980 |
+
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
981 |
+
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
|
982 |
+
"engines": {
|
983 |
+
"node": ">=6"
|
984 |
+
}
|
985 |
+
},
|
986 |
+
"node_modules/source-map-js": {
|
987 |
+
"version": "1.0.2",
|
988 |
+
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
989 |
+
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
990 |
+
"peer": true,
|
991 |
+
"engines": {
|
992 |
+
"node": ">=0.10.0"
|
993 |
+
}
|
994 |
+
},
|
995 |
+
"node_modules/svelte": {
|
996 |
+
"version": "4.2.2",
|
997 |
+
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.2.tgz",
|
998 |
+
"integrity": "sha512-My2tytF2e2NnHSpn2M7/3VdXT4JdTglYVUuSuK/mXL2XtulPYbeBfl8Dm1QiaKRn0zoULRnL+EtfZHHP0k4H3A==",
|
999 |
+
"peer": true,
|
1000 |
+
"dependencies": {
|
1001 |
+
"@ampproject/remapping": "^2.2.1",
|
1002 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
1003 |
+
"@jridgewell/trace-mapping": "^0.3.18",
|
1004 |
+
"acorn": "^8.9.0",
|
1005 |
+
"aria-query": "^5.3.0",
|
1006 |
+
"axobject-query": "^3.2.1",
|
1007 |
+
"code-red": "^1.0.3",
|
1008 |
+
"css-tree": "^2.3.1",
|
1009 |
+
"estree-walker": "^3.0.3",
|
1010 |
+
"is-reference": "^3.0.1",
|
1011 |
+
"locate-character": "^3.0.0",
|
1012 |
+
"magic-string": "^0.30.4",
|
1013 |
+
"periscopic": "^3.1.0"
|
1014 |
+
},
|
1015 |
+
"engines": {
|
1016 |
+
"node": ">=16"
|
1017 |
+
}
|
1018 |
+
},
|
1019 |
+
"node_modules/svelte-i18n": {
|
1020 |
+
"version": "3.7.4",
|
1021 |
+
"resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
|
1022 |
+
"integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
|
1023 |
+
"dependencies": {
|
1024 |
+
"cli-color": "^2.0.3",
|
1025 |
+
"deepmerge": "^4.2.2",
|
1026 |
+
"esbuild": "^0.19.2",
|
1027 |
+
"estree-walker": "^2",
|
1028 |
+
"intl-messageformat": "^9.13.0",
|
1029 |
+
"sade": "^1.8.1",
|
1030 |
+
"tiny-glob": "^0.2.9"
|
1031 |
+
},
|
1032 |
+
"bin": {
|
1033 |
+
"svelte-i18n": "dist/cli.js"
|
1034 |
+
},
|
1035 |
+
"engines": {
|
1036 |
+
"node": ">= 16"
|
1037 |
+
},
|
1038 |
+
"peerDependencies": {
|
1039 |
+
"svelte": "^3 || ^4"
|
1040 |
+
}
|
1041 |
+
},
|
1042 |
+
"node_modules/svelte-i18n/node_modules/estree-walker": {
|
1043 |
+
"version": "2.0.2",
|
1044 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
1045 |
+
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
1046 |
+
},
|
1047 |
+
"node_modules/timers-ext": {
|
1048 |
+
"version": "0.1.7",
|
1049 |
+
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
1050 |
+
"integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
|
1051 |
+
"dependencies": {
|
1052 |
+
"es5-ext": "~0.10.46",
|
1053 |
+
"next-tick": "1"
|
1054 |
+
}
|
1055 |
+
},
|
1056 |
+
"node_modules/tiny-glob": {
|
1057 |
+
"version": "0.2.9",
|
1058 |
+
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
|
1059 |
+
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
|
1060 |
+
"dependencies": {
|
1061 |
+
"globalyzer": "0.1.0",
|
1062 |
+
"globrex": "^0.1.2"
|
1063 |
+
}
|
1064 |
+
},
|
1065 |
+
"node_modules/tslib": {
|
1066 |
+
"version": "2.6.2",
|
1067 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
1068 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
1069 |
+
},
|
1070 |
+
"node_modules/type": {
|
1071 |
+
"version": "1.2.0",
|
1072 |
+
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
1073 |
+
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
1074 |
+
},
|
1075 |
+
"node_modules/ws": {
|
1076 |
+
"version": "8.14.2",
|
1077 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
|
1078 |
+
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
|
1079 |
+
"engines": {
|
1080 |
+
"node": ">=10.0.0"
|
1081 |
+
},
|
1082 |
+
"peerDependencies": {
|
1083 |
+
"bufferutil": "^4.0.1",
|
1084 |
+
"utf-8-validate": ">=5.0.2"
|
1085 |
+
},
|
1086 |
+
"peerDependenciesMeta": {
|
1087 |
+
"bufferutil": {
|
1088 |
+
"optional": true
|
1089 |
+
},
|
1090 |
+
"utf-8-validate": {
|
1091 |
+
"optional": true
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
}
|
1096 |
+
}
|
src/frontend/package.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_multimodalchatbot",
|
3 |
+
"version": "0.4.2",
|
4 |
+
"description": "Gradio UI packages",
|
5 |
+
"type": "module",
|
6 |
+
"author": "",
|
7 |
+
"license": "ISC",
|
8 |
+
"private": false,
|
9 |
+
"dependencies": {
|
10 |
+
"@gradio/atoms": "0.2.0",
|
11 |
+
"@gradio/client": "0.7.1",
|
12 |
+
"@gradio/icons": "0.2.0",
|
13 |
+
"@gradio/markdown": "0.3.0",
|
14 |
+
"@gradio/statustracker": "0.3.0",
|
15 |
+
"@gradio/theme": "0.2.0",
|
16 |
+
"@gradio/upload": "0.3.2",
|
17 |
+
"@gradio/utils": "0.2.0",
|
18 |
+
"@types/dompurify": "^3.0.2",
|
19 |
+
"@types/katex": "^0.16.0",
|
20 |
+
"@types/prismjs": "1.26.1",
|
21 |
+
"dequal": "^2.0.2"
|
22 |
+
},
|
23 |
+
"main_changeset": true,
|
24 |
+
"main": "./Index.svelte",
|
25 |
+
"exports": {
|
26 |
+
".": "./Index.svelte",
|
27 |
+
"./package.json": "./package.json"
|
28 |
+
}
|
29 |
+
}
|
src/frontend/shared/ChatBot.svelte
ADDED
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { format_chat_for_sharing } from "./utils";
|
3 |
+
import type { MultimodalMessage } from "./utils";
|
4 |
+
import { copy } from "@gradio/utils";
|
5 |
+
|
6 |
+
import { dequal } from "dequal/lite";
|
7 |
+
import { beforeUpdate, afterUpdate, createEventDispatcher } from "svelte";
|
8 |
+
import { ShareButton } from "@gradio/atoms";
|
9 |
+
import type { SelectData, LikeData } from "@gradio/utils";
|
10 |
+
import { MarkdownCode as Markdown } from "@gradio/markdown";
|
11 |
+
import { get_fetchable_url_or_file, type FileData } from "@gradio/client";
|
12 |
+
import Copy from "./Copy.svelte";
|
13 |
+
import type { I18nFormatter } from "js/app/src/gradio_helper";
|
14 |
+
import LikeDislike from "./LikeDislike.svelte";
|
15 |
+
import Pending from "./Pending.svelte";
|
16 |
+
|
17 |
+
export let value:
|
18 |
+
| [
|
19 |
+
MultimodalMessage | null,
|
20 |
+
MultimodalMessage | null
|
21 |
+
][]
|
22 |
+
| null;
|
23 |
+
let old_value:
|
24 |
+
| [
|
25 |
+
MultimodalMessage | null,
|
26 |
+
MultimodalMessage | null
|
27 |
+
][]
|
28 |
+
| null = null;
|
29 |
+
export let latex_delimiters: {
|
30 |
+
left: string;
|
31 |
+
right: string;
|
32 |
+
display: boolean;
|
33 |
+
}[];
|
34 |
+
export let pending_message = false;
|
35 |
+
export let selectable = false;
|
36 |
+
export let likeable = false;
|
37 |
+
export let show_share_button = false;
|
38 |
+
export let rtl = false;
|
39 |
+
export let show_copy_button = false;
|
40 |
+
export let avatar_images: [string | null, string | null] = [null, null];
|
41 |
+
export let sanitize_html = true;
|
42 |
+
export let bubble_full_width = true;
|
43 |
+
export let render_markdown = true;
|
44 |
+
export let line_breaks = true;
|
45 |
+
export let root: string;
|
46 |
+
export let proxy_url: null | string;
|
47 |
+
export let i18n: I18nFormatter;
|
48 |
+
export let layout: "bubble" | "panel" = "bubble";
|
49 |
+
|
50 |
+
let div: HTMLDivElement;
|
51 |
+
let autoscroll: boolean;
|
52 |
+
|
53 |
+
const dispatch = createEventDispatcher<{
|
54 |
+
change: undefined;
|
55 |
+
select: SelectData;
|
56 |
+
like: LikeData;
|
57 |
+
}>();
|
58 |
+
|
59 |
+
beforeUpdate(() => {
|
60 |
+
autoscroll =
|
61 |
+
div && div.offsetHeight + div.scrollTop > div.scrollHeight - 100;
|
62 |
+
});
|
63 |
+
|
64 |
+
const scroll = (): void => {
|
65 |
+
if (autoscroll) {
|
66 |
+
div.scrollTo(0, div.scrollHeight);
|
67 |
+
}
|
68 |
+
};
|
69 |
+
afterUpdate(() => {
|
70 |
+
if (autoscroll) {
|
71 |
+
scroll();
|
72 |
+
div.querySelectorAll("img").forEach((n) => {
|
73 |
+
n.addEventListener("load", () => {
|
74 |
+
scroll();
|
75 |
+
});
|
76 |
+
});
|
77 |
+
}
|
78 |
+
});
|
79 |
+
|
80 |
+
$: {
|
81 |
+
if (!dequal(value, old_value)) {
|
82 |
+
old_value = value;
|
83 |
+
dispatch("change");
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
function handle_select(
|
88 |
+
i: number,
|
89 |
+
j: number,
|
90 |
+
message: MultimodalMessage | null
|
91 |
+
): void {
|
92 |
+
dispatch("select", {
|
93 |
+
index: [i, j],
|
94 |
+
value: message
|
95 |
+
});
|
96 |
+
}
|
97 |
+
|
98 |
+
function handle_like(
|
99 |
+
i: number,
|
100 |
+
j: number,
|
101 |
+
message: MultimodalMessage | null,
|
102 |
+
liked: boolean
|
103 |
+
): void {
|
104 |
+
dispatch("like", {
|
105 |
+
index: [i, j],
|
106 |
+
value: message,
|
107 |
+
liked: liked
|
108 |
+
});
|
109 |
+
}
|
110 |
+
</script>
|
111 |
+
|
112 |
+
{#if show_share_button && value !== null && value.length > 0}
|
113 |
+
<div class="share-button">
|
114 |
+
<ShareButton
|
115 |
+
{i18n}
|
116 |
+
on:error
|
117 |
+
on:share
|
118 |
+
formatter={format_chat_for_sharing}
|
119 |
+
{value}
|
120 |
+
/>
|
121 |
+
</div>
|
122 |
+
{/if}
|
123 |
+
|
124 |
+
<div
|
125 |
+
class={layout === "bubble" ? "bubble-wrap" : "panel-wrap"}
|
126 |
+
bind:this={div}
|
127 |
+
role="log"
|
128 |
+
aria-label="chatbot conversation"
|
129 |
+
aria-live="polite"
|
130 |
+
>
|
131 |
+
<div class="message-wrap" class:bubble-gap={layout === "bubble"} use:copy>
|
132 |
+
{#if value !== null}
|
133 |
+
{#each value as message_pair, i}
|
134 |
+
{#each message_pair as message, j}
|
135 |
+
{#if message !== null || pending_message}
|
136 |
+
<div class="message-row {layout} {j == 0 ? 'user-row' : 'bot-row'}">
|
137 |
+
{#if avatar_images[j] !== null}
|
138 |
+
<div class="avatar-container">
|
139 |
+
<img
|
140 |
+
class="avatar-image"
|
141 |
+
src={get_fetchable_url_or_file(
|
142 |
+
avatar_images[j],
|
143 |
+
root,
|
144 |
+
proxy_url
|
145 |
+
)}
|
146 |
+
alt="{j == 0 ? 'user' : 'bot'} avatar"
|
147 |
+
/>
|
148 |
+
</div>
|
149 |
+
{/if}
|
150 |
+
|
151 |
+
<div
|
152 |
+
class="message {j == 0 ? 'user' : 'bot'}"
|
153 |
+
class:message-fit={layout === "bubble" && !bubble_full_width}
|
154 |
+
class:panel-full-width={layout === "panel"}
|
155 |
+
class:message-bubble-border={layout === "bubble"}
|
156 |
+
class:message-markdown-disabled={!render_markdown}
|
157 |
+
>
|
158 |
+
<button
|
159 |
+
data-testid={j == 0 ? "user" : "bot"}
|
160 |
+
class:latest={i === value.length - 1}
|
161 |
+
class:message-markdown-disabled={!render_markdown}
|
162 |
+
class:selectable
|
163 |
+
style:text-align="left"
|
164 |
+
on:click={() => handle_select(i, j, message)}
|
165 |
+
on:keydown={(e) => {
|
166 |
+
if (e.key === "Enter") {
|
167 |
+
handle_select(i, j, message);
|
168 |
+
}
|
169 |
+
}}
|
170 |
+
dir={rtl ? "rtl" : "ltr"}
|
171 |
+
aria-label={(j == 0 ? "user" : "bot") +
|
172 |
+
"'s message:' " +
|
173 |
+
message}
|
174 |
+
>
|
175 |
+
<Markdown
|
176 |
+
message={message.text}
|
177 |
+
{latex_delimiters}
|
178 |
+
{sanitize_html}
|
179 |
+
{render_markdown}
|
180 |
+
{line_breaks}
|
181 |
+
on:load={scroll}
|
182 |
+
/>
|
183 |
+
{#each message.files as file, k}
|
184 |
+
{#if file !== null && file.file.mime_type?.includes("audio")}
|
185 |
+
<audio
|
186 |
+
data-testid="chatbot-audio"
|
187 |
+
controls
|
188 |
+
preload="metadata"
|
189 |
+
src={file.file?.url}
|
190 |
+
title={file.alt_text}
|
191 |
+
on:play
|
192 |
+
on:pause
|
193 |
+
on:ended
|
194 |
+
/>
|
195 |
+
{:else if message !== null && file.file?.mime_type?.includes("video")}
|
196 |
+
<video
|
197 |
+
data-testid="chatbot-video"
|
198 |
+
controls
|
199 |
+
src={file.file?.url}
|
200 |
+
title={file.alt_text}
|
201 |
+
preload="auto"
|
202 |
+
on:play
|
203 |
+
on:pause
|
204 |
+
on:ended
|
205 |
+
>
|
206 |
+
<track kind="captions" />
|
207 |
+
</video>
|
208 |
+
{:else if message !== null && file.file?.mime_type?.includes("image")}
|
209 |
+
<img
|
210 |
+
data-testid="chatbot-image"
|
211 |
+
src={file.file?.url}
|
212 |
+
alt={file.alt_text}
|
213 |
+
/>
|
214 |
+
{:else if message !== null && file.file?.url !== null}
|
215 |
+
<a
|
216 |
+
data-testid="chatbot-file"
|
217 |
+
href={file.file?.url}
|
218 |
+
target="_blank"
|
219 |
+
download={window.__is_colab__
|
220 |
+
? null
|
221 |
+
: file.file?.orig_name || file.file?.path}
|
222 |
+
>
|
223 |
+
{file.file?.orig_name || file.file?.path}
|
224 |
+
</a>
|
225 |
+
{:else if pending_message && j === 1}
|
226 |
+
<Pending {layout} />
|
227 |
+
{/if}
|
228 |
+
{/each}
|
229 |
+
</button>
|
230 |
+
</div>
|
231 |
+
{#if (likeable && j !== 0) || (show_copy_button && message && typeof message === "string")}
|
232 |
+
<div
|
233 |
+
class="message-buttons-{j == 0
|
234 |
+
? 'user'
|
235 |
+
: 'bot'} message-buttons-{layout} {avatar_images[j] !==
|
236 |
+
null && 'with-avatar'}"
|
237 |
+
class:message-buttons-fit={layout === "bubble" &&
|
238 |
+
!bubble_full_width}
|
239 |
+
class:bubble-buttons-user={layout === "bubble"}
|
240 |
+
>
|
241 |
+
{#if likeable && j == 1}
|
242 |
+
<LikeDislike
|
243 |
+
action="like"
|
244 |
+
handle_action={() => handle_like(i, j, message, true)}
|
245 |
+
/>
|
246 |
+
<LikeDislike
|
247 |
+
action="dislike"
|
248 |
+
handle_action={() => handle_like(i, j, message, false)}
|
249 |
+
/>
|
250 |
+
{/if}
|
251 |
+
{#if show_copy_button && message && typeof message === "string"}
|
252 |
+
<Copy value={message} />
|
253 |
+
{/if}
|
254 |
+
</div>
|
255 |
+
{/if}
|
256 |
+
</div>
|
257 |
+
{/if}
|
258 |
+
{/each}
|
259 |
+
{/each}
|
260 |
+
{/if}
|
261 |
+
</div>
|
262 |
+
</div>
|
263 |
+
|
264 |
+
<style>
|
265 |
+
.bubble-wrap {
|
266 |
+
padding: var(--block-padding);
|
267 |
+
width: 100%;
|
268 |
+
overflow-y: auto;
|
269 |
+
}
|
270 |
+
|
271 |
+
.panel-wrap {
|
272 |
+
width: 100%;
|
273 |
+
overflow-y: auto;
|
274 |
+
}
|
275 |
+
|
276 |
+
.message-wrap {
|
277 |
+
display: flex;
|
278 |
+
flex-direction: column;
|
279 |
+
justify-content: space-between;
|
280 |
+
}
|
281 |
+
|
282 |
+
.bubble-gap {
|
283 |
+
gap: calc(var(--spacing-xxl) + var(--spacing-lg));
|
284 |
+
}
|
285 |
+
|
286 |
+
.message-wrap > div :not(.avatar-container) :global(img) {
|
287 |
+
border-radius: 13px;
|
288 |
+
max-width: 30vw;
|
289 |
+
}
|
290 |
+
|
291 |
+
.message-wrap > div :global(p:not(:first-child)) {
|
292 |
+
margin-top: var(--spacing-xxl);
|
293 |
+
}
|
294 |
+
|
295 |
+
.message-wrap :global(audio) {
|
296 |
+
width: 100%;
|
297 |
+
}
|
298 |
+
|
299 |
+
.message {
|
300 |
+
position: relative;
|
301 |
+
display: flex;
|
302 |
+
flex-direction: column;
|
303 |
+
align-self: flex-end;
|
304 |
+
text-align: left;
|
305 |
+
background: var(--background-fill-secondary);
|
306 |
+
width: calc(100% - var(--spacing-xxl));
|
307 |
+
color: var(--body-text-color);
|
308 |
+
font-size: var(--text-lg);
|
309 |
+
line-height: var(--line-lg);
|
310 |
+
overflow-wrap: break-word;
|
311 |
+
overflow-x: hidden;
|
312 |
+
padding-right: calc(var(--spacing-xxl) + var(--spacing-md));
|
313 |
+
padding: calc(var(--spacing-xxl) + var(--spacing-sm));
|
314 |
+
}
|
315 |
+
|
316 |
+
.message-bubble-border {
|
317 |
+
border-width: 1px;
|
318 |
+
border-radius: var(--radius-xxl);
|
319 |
+
}
|
320 |
+
|
321 |
+
.message-fit {
|
322 |
+
width: fit-content !important;
|
323 |
+
}
|
324 |
+
|
325 |
+
.panel-full-width {
|
326 |
+
padding: calc(var(--spacing-xxl) * 2);
|
327 |
+
width: 100%;
|
328 |
+
}
|
329 |
+
.message-markdown-disabled {
|
330 |
+
white-space: pre-line;
|
331 |
+
}
|
332 |
+
|
333 |
+
@media (max-width: 480px) {
|
334 |
+
.panel-full-width {
|
335 |
+
padding: calc(var(--spacing-xxl) * 2);
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
.user {
|
340 |
+
align-self: flex-start;
|
341 |
+
border-bottom-right-radius: 0;
|
342 |
+
text-align: right;
|
343 |
+
}
|
344 |
+
.bot {
|
345 |
+
border-bottom-left-radius: 0;
|
346 |
+
}
|
347 |
+
|
348 |
+
/* Colors */
|
349 |
+
.bot {
|
350 |
+
border-color: var(--border-color-primary);
|
351 |
+
background: var(--background-fill-secondary);
|
352 |
+
}
|
353 |
+
|
354 |
+
.user {
|
355 |
+
border-color: var(--border-color-accent-subdued);
|
356 |
+
background-color: var(--color-accent-soft);
|
357 |
+
}
|
358 |
+
.message-row {
|
359 |
+
display: flex;
|
360 |
+
flex-direction: row;
|
361 |
+
position: relative;
|
362 |
+
}
|
363 |
+
|
364 |
+
.message-row.panel.user-row {
|
365 |
+
background: var(--color-accent-soft);
|
366 |
+
}
|
367 |
+
|
368 |
+
.message-row.panel.bot-row {
|
369 |
+
background: var(--background-fill-secondary);
|
370 |
+
}
|
371 |
+
|
372 |
+
.message-row:last-of-type {
|
373 |
+
margin-bottom: var(--spacing-xxl);
|
374 |
+
}
|
375 |
+
|
376 |
+
.user-row.bubble {
|
377 |
+
flex-direction: row;
|
378 |
+
justify-content: flex-end;
|
379 |
+
}
|
380 |
+
@media (max-width: 480px) {
|
381 |
+
.user-row.bubble {
|
382 |
+
align-self: flex-end;
|
383 |
+
}
|
384 |
+
|
385 |
+
.bot-row.bubble {
|
386 |
+
align-self: flex-start;
|
387 |
+
}
|
388 |
+
.message {
|
389 |
+
width: auto;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
.avatar-container {
|
393 |
+
align-self: flex-end;
|
394 |
+
position: relative;
|
395 |
+
justify-content: center;
|
396 |
+
width: 35px;
|
397 |
+
height: 35px;
|
398 |
+
flex-shrink: 0;
|
399 |
+
bottom: 0;
|
400 |
+
}
|
401 |
+
.user-row.bubble > .avatar-container {
|
402 |
+
order: 2;
|
403 |
+
margin-left: 10px;
|
404 |
+
}
|
405 |
+
.bot-row.bubble > .avatar-container {
|
406 |
+
margin-right: 10px;
|
407 |
+
}
|
408 |
+
|
409 |
+
.panel > .avatar-container {
|
410 |
+
margin-left: 25px;
|
411 |
+
align-self: center;
|
412 |
+
}
|
413 |
+
img.avatar-image {
|
414 |
+
width: 100%;
|
415 |
+
height: 100%;
|
416 |
+
object-fit: cover;
|
417 |
+
border-radius: 50%;
|
418 |
+
}
|
419 |
+
|
420 |
+
.message-buttons-user,
|
421 |
+
.message-buttons-bot {
|
422 |
+
border-radius: var(--radius-md);
|
423 |
+
display: flex;
|
424 |
+
align-items: center;
|
425 |
+
bottom: 0;
|
426 |
+
height: var(--size-7);
|
427 |
+
align-self: self-end;
|
428 |
+
position: absolute;
|
429 |
+
bottom: -15px;
|
430 |
+
margin: 2px;
|
431 |
+
padding-left: 5px;
|
432 |
+
z-index: 1;
|
433 |
+
}
|
434 |
+
.message-buttons-bot {
|
435 |
+
left: 10px;
|
436 |
+
}
|
437 |
+
.message-buttons-user {
|
438 |
+
right: 5px;
|
439 |
+
}
|
440 |
+
|
441 |
+
.message-buttons-bot.message-buttons-bubble.with-avatar {
|
442 |
+
left: 50px;
|
443 |
+
}
|
444 |
+
.message-buttons-user.message-buttons-bubble.with-avatar {
|
445 |
+
right: 50px;
|
446 |
+
}
|
447 |
+
|
448 |
+
.message-buttons-bubble {
|
449 |
+
border: 1px solid var(--border-color-accent);
|
450 |
+
background: var(--background-fill-secondary);
|
451 |
+
}
|
452 |
+
|
453 |
+
.message-buttons-panel {
|
454 |
+
left: unset;
|
455 |
+
right: 0px;
|
456 |
+
top: 0px;
|
457 |
+
}
|
458 |
+
|
459 |
+
.share-button {
|
460 |
+
position: absolute;
|
461 |
+
top: 4px;
|
462 |
+
right: 6px;
|
463 |
+
}
|
464 |
+
|
465 |
+
.selectable {
|
466 |
+
cursor: pointer;
|
467 |
+
}
|
468 |
+
|
469 |
+
@keyframes dot-flashing {
|
470 |
+
0% {
|
471 |
+
opacity: 0.8;
|
472 |
+
}
|
473 |
+
50% {
|
474 |
+
opacity: 0.5;
|
475 |
+
}
|
476 |
+
100% {
|
477 |
+
opacity: 0.8;
|
478 |
+
}
|
479 |
+
}
|
480 |
+
.message-wrap .message :global(img) {
|
481 |
+
margin: var(--size-2);
|
482 |
+
max-height: 200px;
|
483 |
+
}
|
484 |
+
.message-wrap .message :global(a) {
|
485 |
+
color: var(--color-text-link);
|
486 |
+
text-decoration: underline;
|
487 |
+
}
|
488 |
+
|
489 |
+
.message-wrap .bot :global(table),
|
490 |
+
.message-wrap .bot :global(tr),
|
491 |
+
.message-wrap .bot :global(td),
|
492 |
+
.message-wrap .bot :global(th) {
|
493 |
+
border: 1px solid var(--border-color-primary);
|
494 |
+
}
|
495 |
+
|
496 |
+
.message-wrap .user :global(table),
|
497 |
+
.message-wrap .user :global(tr),
|
498 |
+
.message-wrap .user :global(td),
|
499 |
+
.message-wrap .user :global(th) {
|
500 |
+
border: 1px solid var(--border-color-accent);
|
501 |
+
}
|
502 |
+
|
503 |
+
/* Lists */
|
504 |
+
.message-wrap :global(ol),
|
505 |
+
.message-wrap :global(ul) {
|
506 |
+
padding-inline-start: 2em;
|
507 |
+
}
|
508 |
+
|
509 |
+
/* KaTeX */
|
510 |
+
.message-wrap :global(span.katex) {
|
511 |
+
font-size: var(--text-lg);
|
512 |
+
direction: ltr;
|
513 |
+
}
|
514 |
+
|
515 |
+
/* Copy button */
|
516 |
+
.message-wrap :global(div[class*="code_wrap"] > button) {
|
517 |
+
position: absolute;
|
518 |
+
top: var(--spacing-md);
|
519 |
+
right: var(--spacing-md);
|
520 |
+
z-index: 1;
|
521 |
+
cursor: pointer;
|
522 |
+
border-bottom-left-radius: var(--radius-sm);
|
523 |
+
padding: 5px;
|
524 |
+
padding: var(--spacing-md);
|
525 |
+
width: 25px;
|
526 |
+
height: 25px;
|
527 |
+
}
|
528 |
+
|
529 |
+
.message-wrap :global(code > button > span) {
|
530 |
+
position: absolute;
|
531 |
+
top: var(--spacing-md);
|
532 |
+
right: var(--spacing-md);
|
533 |
+
width: 12px;
|
534 |
+
height: 12px;
|
535 |
+
}
|
536 |
+
.message-wrap :global(.check) {
|
537 |
+
position: absolute;
|
538 |
+
top: 0;
|
539 |
+
right: 0;
|
540 |
+
opacity: 0;
|
541 |
+
z-index: var(--layer-top);
|
542 |
+
transition: opacity 0.2s;
|
543 |
+
background: var(--background-fill-primary);
|
544 |
+
padding: var(--size-1);
|
545 |
+
width: 100%;
|
546 |
+
height: 100%;
|
547 |
+
color: var(--body-text-color);
|
548 |
+
}
|
549 |
+
|
550 |
+
.message-wrap :global(pre) {
|
551 |
+
position: relative;
|
552 |
+
}
|
553 |
+
</style>
|
src/frontend/shared/Copy.svelte
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onDestroy } from "svelte";
|
3 |
+
import { Copy, Check } from "@gradio/icons";
|
4 |
+
|
5 |
+
let copied = false;
|
6 |
+
export let value: string;
|
7 |
+
let timer: NodeJS.Timeout;
|
8 |
+
|
9 |
+
function copy_feedback(): void {
|
10 |
+
copied = true;
|
11 |
+
if (timer) clearTimeout(timer);
|
12 |
+
timer = setTimeout(() => {
|
13 |
+
copied = false;
|
14 |
+
}, 2000);
|
15 |
+
}
|
16 |
+
|
17 |
+
async function handle_copy(): Promise<void> {
|
18 |
+
if ("clipboard" in navigator) {
|
19 |
+
await navigator.clipboard.writeText(value);
|
20 |
+
copy_feedback();
|
21 |
+
} else {
|
22 |
+
const textArea = document.createElement("textarea");
|
23 |
+
textArea.value = value;
|
24 |
+
|
25 |
+
textArea.style.position = "absolute";
|
26 |
+
textArea.style.left = "-999999px";
|
27 |
+
|
28 |
+
document.body.prepend(textArea);
|
29 |
+
textArea.select();
|
30 |
+
|
31 |
+
try {
|
32 |
+
document.execCommand("copy");
|
33 |
+
copy_feedback();
|
34 |
+
} catch (error) {
|
35 |
+
console.error(error);
|
36 |
+
} finally {
|
37 |
+
textArea.remove();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
onDestroy(() => {
|
43 |
+
if (timer) clearTimeout(timer);
|
44 |
+
});
|
45 |
+
</script>
|
46 |
+
|
47 |
+
<button
|
48 |
+
on:click={handle_copy}
|
49 |
+
title="copy"
|
50 |
+
aria-label={copied ? "Copied message" : "Copy message"}
|
51 |
+
>
|
52 |
+
{#if !copied}
|
53 |
+
<Copy />
|
54 |
+
{/if}
|
55 |
+
{#if copied}
|
56 |
+
<Check />
|
57 |
+
{/if}
|
58 |
+
</button>
|
59 |
+
|
60 |
+
<style>
|
61 |
+
button {
|
62 |
+
position: relative;
|
63 |
+
top: 0;
|
64 |
+
right: 0;
|
65 |
+
cursor: pointer;
|
66 |
+
color: var(--body-text-color-subdued);
|
67 |
+
margin-right: 5px;
|
68 |
+
}
|
69 |
+
|
70 |
+
button:hover {
|
71 |
+
color: var(--body-text-color);
|
72 |
+
}
|
73 |
+
</style>
|
src/frontend/shared/LikeDislike.svelte
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { Like } from "@gradio/icons";
|
3 |
+
import { Dislike } from "@gradio/icons";
|
4 |
+
|
5 |
+
export let action: "like" | "dislike";
|
6 |
+
export let handle_action: () => void;
|
7 |
+
|
8 |
+
let actioned = false;
|
9 |
+
let Icon = action === "like" ? Like : Dislike;
|
10 |
+
|
11 |
+
function action_feedback(): void {
|
12 |
+
actioned = true;
|
13 |
+
}
|
14 |
+
</script>
|
15 |
+
|
16 |
+
<button
|
17 |
+
on:click={() => {
|
18 |
+
action_feedback();
|
19 |
+
handle_action();
|
20 |
+
}}
|
21 |
+
on:keydown={(e) => {
|
22 |
+
if (e.key === "Enter") {
|
23 |
+
action_feedback();
|
24 |
+
handle_action();
|
25 |
+
}
|
26 |
+
}}
|
27 |
+
title={action + " message"}
|
28 |
+
aria-label={actioned ? `clicked ${action}` : action}
|
29 |
+
>
|
30 |
+
<Icon {actioned} />
|
31 |
+
</button>
|
32 |
+
|
33 |
+
<style>
|
34 |
+
button {
|
35 |
+
position: relative;
|
36 |
+
top: 0;
|
37 |
+
right: 0;
|
38 |
+
cursor: pointer;
|
39 |
+
color: var(--body-text-color-subdued);
|
40 |
+
width: 17px;
|
41 |
+
height: 17px;
|
42 |
+
margin-right: 5px;
|
43 |
+
}
|
44 |
+
|
45 |
+
button:hover,
|
46 |
+
button:focus {
|
47 |
+
color: var(--body-text-color);
|
48 |
+
}
|
49 |
+
</style>
|
src/frontend/shared/Pending.svelte
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
export let layout = "bubble";
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<div
|
6 |
+
class="message pending"
|
7 |
+
role="status"
|
8 |
+
aria-label="Loading response"
|
9 |
+
aria-live="polite"
|
10 |
+
style:border-radius={layout === "bubble" ? "var(--radius-xxl)" : "none"}
|
11 |
+
>
|
12 |
+
<span class="sr-only">Loading content</span>
|
13 |
+
<div class="dot-flashing" />
|
14 |
+
|
15 |
+
<div class="dot-flashing" />
|
16 |
+
|
17 |
+
<div class="dot-flashing" />
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<style>
|
21 |
+
.pending {
|
22 |
+
background: var(--background-fill-secondary);
|
23 |
+
display: flex;
|
24 |
+
flex-direction: row;
|
25 |
+
justify-content: center;
|
26 |
+
align-items: center;
|
27 |
+
align-self: center;
|
28 |
+
gap: 2px;
|
29 |
+
width: 100%;
|
30 |
+
height: 100%;
|
31 |
+
}
|
32 |
+
.dot-flashing {
|
33 |
+
animation: dot-flashing 1s infinite linear alternate;
|
34 |
+
border-radius: 5px;
|
35 |
+
background-color: var(--body-text-color);
|
36 |
+
width: 5px;
|
37 |
+
height: 5px;
|
38 |
+
color: var(--body-text-color);
|
39 |
+
}
|
40 |
+
.dot-flashing:nth-child(2) {
|
41 |
+
animation-delay: 0.33s;
|
42 |
+
}
|
43 |
+
.dot-flashing:nth-child(3) {
|
44 |
+
animation-delay: 0.66s;
|
45 |
+
}
|
46 |
+
</style>
|
src/frontend/shared/autorender.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
declare module "katex/dist/contrib/auto-render.js";
|
src/frontend/shared/utils.ts
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FileData } from "@gradio/client";
|
2 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
3 |
+
|
4 |
+
export type FileMessage = {
|
5 |
+
file: FileData;
|
6 |
+
alt_text?: string;
|
7 |
+
};
|
8 |
+
|
9 |
+
|
10 |
+
export type MultimodalMessage = {
|
11 |
+
text: string;
|
12 |
+
files?: FileMessage[];
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
export const format_chat_for_sharing = async (
|
17 |
+
chat: [string | FileData | null, string | FileData | null][]
|
18 |
+
): Promise<string> => {
|
19 |
+
let messages = await Promise.all(
|
20 |
+
chat.map(async (message_pair) => {
|
21 |
+
return await Promise.all(
|
22 |
+
message_pair.map(async (message, i) => {
|
23 |
+
if (message === null) return "";
|
24 |
+
let speaker_emoji = i === 0 ? "😃" : "🤖";
|
25 |
+
let html_content = "";
|
26 |
+
|
27 |
+
if (typeof message === "string") {
|
28 |
+
const regexPatterns = {
|
29 |
+
audio: /<audio.*?src="(\/file=.*?)"/g,
|
30 |
+
video: /<video.*?src="(\/file=.*?)"/g,
|
31 |
+
image: /<img.*?src="(\/file=.*?)".*?\/>|!\[.*?\]\((\/file=.*?)\)/g
|
32 |
+
};
|
33 |
+
|
34 |
+
html_content = message;
|
35 |
+
|
36 |
+
for (let [_, regex] of Object.entries(regexPatterns)) {
|
37 |
+
let match;
|
38 |
+
|
39 |
+
while ((match = regex.exec(message)) !== null) {
|
40 |
+
const fileUrl = match[1] || match[2];
|
41 |
+
const newUrl = await uploadToHuggingFace(fileUrl, "url");
|
42 |
+
html_content = html_content.replace(fileUrl, newUrl);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
} else {
|
46 |
+
if (!message?.url) return "";
|
47 |
+
const file_url = await uploadToHuggingFace(message.url, "url");
|
48 |
+
if (message.mime_type?.includes("audio")) {
|
49 |
+
html_content = `<audio controls src="${file_url}"></audio>`;
|
50 |
+
} else if (message.mime_type?.includes("video")) {
|
51 |
+
html_content = file_url;
|
52 |
+
} else if (message.mime_type?.includes("image")) {
|
53 |
+
html_content = `<img src="${file_url}" />`;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return `${speaker_emoji}: ${html_content}`;
|
58 |
+
})
|
59 |
+
);
|
60 |
+
})
|
61 |
+
);
|
62 |
+
return messages
|
63 |
+
.map((message_pair) =>
|
64 |
+
message_pair.join(
|
65 |
+
message_pair[0] !== "" && message_pair[1] !== "" ? "\n" : ""
|
66 |
+
)
|
67 |
+
)
|
68 |
+
.join("\n");
|
69 |
+
};
|
src/pyproject.toml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = [
|
3 |
+
"hatchling",
|
4 |
+
"hatch-requirements-txt",
|
5 |
+
"hatch-fancy-pypi-readme>=22.5.0",
|
6 |
+
]
|
7 |
+
build-backend = "hatchling.build"
|
8 |
+
|
9 |
+
[project]
|
10 |
+
name = "gradio_multimodalchatbot"
|
11 |
+
version = "0.0.1"
|
12 |
+
description = "Python library for easily interacting with trained machine learning models"
|
13 |
+
readme = "README.md"
|
14 |
+
license = "Apache-2.0"
|
15 |
+
requires-python = ">=3.8"
|
16 |
+
authors = [{ name = "Freddy Boulton", email = "freddy@huggingface.co" }]
|
17 |
+
keywords = [
|
18 |
+
"machine learning",
|
19 |
+
"reproducibility",
|
20 |
+
"visualization",
|
21 |
+
"gradio",
|
22 |
+
"gradio custom component",
|
23 |
+
"gradio-template-Chatbot"
|
24 |
+
]
|
25 |
+
# Add dependencies here
|
26 |
+
dependencies = ["gradio>=4.0,<5.0"]
|
27 |
+
classifiers = [
|
28 |
+
'Development Status :: 3 - Alpha',
|
29 |
+
'License :: OSI Approved :: Apache Software License',
|
30 |
+
'Operating System :: OS Independent',
|
31 |
+
'Programming Language :: Python :: 3',
|
32 |
+
'Programming Language :: Python :: 3 :: Only',
|
33 |
+
'Programming Language :: Python :: 3.8',
|
34 |
+
'Programming Language :: Python :: 3.9',
|
35 |
+
'Programming Language :: Python :: 3.10',
|
36 |
+
'Programming Language :: Python :: 3.11',
|
37 |
+
'Topic :: Scientific/Engineering',
|
38 |
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
39 |
+
'Topic :: Scientific/Engineering :: Visualization',
|
40 |
+
]
|
41 |
+
|
42 |
+
[project.optional-dependencies]
|
43 |
+
dev = ["build", "twine"]
|
44 |
+
|
45 |
+
[tool.hatch.build]
|
46 |
+
artifacts = ["/backend/gradio_multimodalchatbot/templates", "*.pyi", "backend/gradio_multimodalchatbot/templates"]
|
47 |
+
|
48 |
+
[tool.hatch.build.targets.wheel]
|
49 |
+
packages = ["/backend/gradio_multimodalchatbot"]
|
world.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:71944d7430c461f0cd6e7fd10cee7eb72786352a3678fc7bc0ae3d410f72aece
|
3 |
+
size 1570024
|