Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -0
- README.md +11 -4
- __init__.py +0 -0
- app.py +14 -0
- requirements.txt +1 -0
- src/.gitignore +9 -0
- src/README.md +10 -0
- src/backend/gradio_gptchatbot/__init__.py +4 -0
- src/backend/gradio_gptchatbot/gptchatbot.py +220 -0
- src/backend/gradio_gptchatbot/gptchatbot.pyi +340 -0
- src/demo/__init__.py +0 -0
- src/demo/app.py +14 -0
- src/frontend/Index.svelte +152 -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 +60 -0
- src/frontend/shared/autorender.d.ts +1 -0
- src/frontend/shared/utils.ts +57 -0
- src/pyproject.toml +42 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
WORKDIR /code
|
5 |
+
|
6 |
+
COPY --link --chown=1000 . .
|
7 |
+
|
8 |
+
RUN mkdir -p /tmp/cache/
|
9 |
+
RUN chmod a+rwx -R /tmp/cache/
|
10 |
+
ENV TRANSFORMERS_CACHE=/tmp/cache/
|
11 |
+
|
12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
13 |
+
|
14 |
+
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
15 |
+
|
16 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
colorFrom:
|
5 |
colorTo: purple
|
6 |
sdk: docker
|
7 |
pinned: false
|
|
|
8 |
---
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
---
|
3 |
+
tags: [gradio-custom-component,gradio-template-Chatbot,chatbot]
|
4 |
+
title: gradio_gptchatbot V0.0.1
|
5 |
+
colorFrom: blue
|
6 |
colorTo: purple
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
+
license: apache-2.0
|
10 |
---
|
11 |
|
12 |
+
|
13 |
+
# Name: gradio_gptchatbot
|
14 |
+
|
15 |
+
Description: a GPT-style Chatbot component
|
16 |
+
|
17 |
+
Install with: pip install gradio_gptchatbot
|
__init__.py
ADDED
File without changes
|
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_gptchatbot import GPTChatbot
|
4 |
+
|
5 |
+
|
6 |
+
example = GPTChatbot().example_inputs()
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
with gr.Row():
|
10 |
+
GPTChatbot(label="Blank"), # blank component
|
11 |
+
GPTChatbot(value=example, label="Populated"), # populated component
|
12 |
+
|
13 |
+
|
14 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_gptchatbot-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_gptchatbot
|
3 |
+
A Custom Gradio component.
|
4 |
+
|
5 |
+
## Example usage
|
6 |
+
|
7 |
+
```python
|
8 |
+
import gradio as gr
|
9 |
+
from gradio_gptchatbot import GPTChatbot
|
10 |
+
```
|
src/backend/gradio_gptchatbot/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .gptchatbot import GPTChatbot
|
3 |
+
|
4 |
+
__all__ = ['GPTChatbot']
|
src/backend/gradio_gptchatbot/gptchatbot.py
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 processing_utils, 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 |
+
|
29 |
+
@document()
|
30 |
+
class GPTChatbot(Component):
|
31 |
+
"""
|
32 |
+
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 GPTChatbot, and other kinds of files which are displayed as links.
|
33 |
+
Preprocessing: passes the messages in the GPTChatbot 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.
|
34 |
+
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 GPTChatbot, or (3) None, in which case the message is not displayed.
|
35 |
+
|
36 |
+
Demos: chatbot_simple, chatbot_multimodal
|
37 |
+
Guides: creating-a-chatbot
|
38 |
+
"""
|
39 |
+
|
40 |
+
EVENTS = [Events.change, Events.select, Events.like]
|
41 |
+
data_model = ChatbotData
|
42 |
+
|
43 |
+
def __init__(
|
44 |
+
self,
|
45 |
+
value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
|
46 |
+
| Callable
|
47 |
+
| None = None,
|
48 |
+
*,
|
49 |
+
label: str | None = None,
|
50 |
+
every: float | None = None,
|
51 |
+
show_label: bool | None = None,
|
52 |
+
container: bool = True,
|
53 |
+
scale: int | None = None,
|
54 |
+
min_width: int = 160,
|
55 |
+
visible: bool = True,
|
56 |
+
elem_id: str | None = None,
|
57 |
+
elem_classes: list[str] | str | None = None,
|
58 |
+
render: bool = True,
|
59 |
+
height: int | None = None,
|
60 |
+
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
61 |
+
rtl: bool = False,
|
62 |
+
show_share_button: bool | None = None,
|
63 |
+
show_copy_button: bool = False,
|
64 |
+
avatar_images: tuple[str | Path | None, str | Path | None] | None = None,
|
65 |
+
sanitize_html: bool = True,
|
66 |
+
render_markdown: bool = True,
|
67 |
+
bubble_full_width: bool = True,
|
68 |
+
line_breaks: bool = True,
|
69 |
+
likeable: bool = False,
|
70 |
+
layout: Literal["panel", "bubble"] | None = None,
|
71 |
+
):
|
72 |
+
"""
|
73 |
+
Parameters:
|
74 |
+
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.
|
75 |
+
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.
|
76 |
+
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.
|
77 |
+
show_label: if True, will display label.
|
78 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
79 |
+
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.
|
80 |
+
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.
|
81 |
+
visible: If False, component will be hidden.
|
82 |
+
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.
|
83 |
+
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.
|
84 |
+
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.
|
85 |
+
height: height of the component in pixels.
|
86 |
+
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).
|
87 |
+
rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
|
88 |
+
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.
|
89 |
+
show_copy_button: If True, will show a copy button for each chatbot message.
|
90 |
+
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.
|
91 |
+
sanitize_html: If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.
|
92 |
+
render_markdown: If False, will disable Markdown rendering for chatbot messages.
|
93 |
+
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.
|
94 |
+
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.
|
95 |
+
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.
|
96 |
+
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".
|
97 |
+
"""
|
98 |
+
self.likeable = likeable
|
99 |
+
self.height = height
|
100 |
+
self.rtl = rtl
|
101 |
+
if latex_delimiters is None:
|
102 |
+
latex_delimiters = [{"left": "$$", "right": "$$", "display": True}]
|
103 |
+
self.latex_delimiters = latex_delimiters
|
104 |
+
self.show_share_button = (
|
105 |
+
(utils.get_space() is not None)
|
106 |
+
if show_share_button is None
|
107 |
+
else show_share_button
|
108 |
+
)
|
109 |
+
self.render_markdown = render_markdown
|
110 |
+
self.show_copy_button = show_copy_button
|
111 |
+
self.sanitize_html = sanitize_html
|
112 |
+
self.bubble_full_width = bubble_full_width
|
113 |
+
self.line_breaks = line_breaks
|
114 |
+
self.layout = layout
|
115 |
+
super().__init__(
|
116 |
+
label=label,
|
117 |
+
every=every,
|
118 |
+
show_label=show_label,
|
119 |
+
container=container,
|
120 |
+
scale=scale,
|
121 |
+
min_width=min_width,
|
122 |
+
visible=visible,
|
123 |
+
elem_id=elem_id,
|
124 |
+
elem_classes=elem_classes,
|
125 |
+
render=render,
|
126 |
+
value=value,
|
127 |
+
)
|
128 |
+
self.avatar_images: list[str | None] = [None, None]
|
129 |
+
if avatar_images is None:
|
130 |
+
pass
|
131 |
+
else:
|
132 |
+
self.avatar_images = [
|
133 |
+
processing_utils.move_resource_to_block_cache(avatar_images[0], self),
|
134 |
+
processing_utils.move_resource_to_block_cache(avatar_images[1], self),
|
135 |
+
]
|
136 |
+
|
137 |
+
def _preprocess_chat_messages(
|
138 |
+
self, chat_message: str | FileMessage | None
|
139 |
+
) -> str | tuple[str | None] | tuple[str | None, str] | None:
|
140 |
+
if chat_message is None:
|
141 |
+
return None
|
142 |
+
elif isinstance(chat_message, FileMessage):
|
143 |
+
if chat_message.alt_text is not None:
|
144 |
+
return (chat_message.file.path, chat_message.alt_text)
|
145 |
+
else:
|
146 |
+
return (chat_message.file.path,)
|
147 |
+
elif isinstance(chat_message, str):
|
148 |
+
return chat_message
|
149 |
+
else:
|
150 |
+
raise ValueError(f"Invalid message for GPTChatbot component: {chat_message}")
|
151 |
+
|
152 |
+
def preprocess(
|
153 |
+
self,
|
154 |
+
payload: ChatbotData,
|
155 |
+
) -> list[list[str | tuple[str] | tuple[str, str] | None]]:
|
156 |
+
if payload is None:
|
157 |
+
return payload
|
158 |
+
processed_messages = []
|
159 |
+
for message_pair in payload.root:
|
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._preprocess_chat_messages(message_pair[0]),
|
171 |
+
self._preprocess_chat_messages(message_pair[1]),
|
172 |
+
]
|
173 |
+
)
|
174 |
+
return processed_messages
|
175 |
+
|
176 |
+
def _postprocess_chat_messages(
|
177 |
+
self, chat_message: str | tuple | list | None
|
178 |
+
) -> str | FileMessage | None:
|
179 |
+
if chat_message is None:
|
180 |
+
return None
|
181 |
+
elif isinstance(chat_message, (tuple, list)):
|
182 |
+
filepath = str(chat_message[0])
|
183 |
+
|
184 |
+
mime_type = client_utils.get_mimetype(filepath)
|
185 |
+
return FileMessage(
|
186 |
+
file=FileData(path=filepath, mime_type=mime_type),
|
187 |
+
alt_text=chat_message[1] if len(chat_message) > 1 else None,
|
188 |
+
)
|
189 |
+
elif isinstance(chat_message, str):
|
190 |
+
chat_message = inspect.cleandoc(chat_message)
|
191 |
+
return chat_message
|
192 |
+
else:
|
193 |
+
raise ValueError(f"Invalid message for GPTChatbot component: {chat_message}")
|
194 |
+
|
195 |
+
def postprocess(
|
196 |
+
self,
|
197 |
+
value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple],
|
198 |
+
) -> ChatbotData:
|
199 |
+
if value is None:
|
200 |
+
return ChatbotData(root=[])
|
201 |
+
processed_messages = []
|
202 |
+
for message_pair in value:
|
203 |
+
if not isinstance(message_pair, (tuple, list)):
|
204 |
+
raise TypeError(
|
205 |
+
f"Expected a list of lists or list of tuples. Received: {message_pair}"
|
206 |
+
)
|
207 |
+
if len(message_pair) != 2:
|
208 |
+
raise TypeError(
|
209 |
+
f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
|
210 |
+
)
|
211 |
+
processed_messages.append(
|
212 |
+
[
|
213 |
+
self._postprocess_chat_messages(message_pair[0]),
|
214 |
+
self._postprocess_chat_messages(message_pair[1]),
|
215 |
+
]
|
216 |
+
)
|
217 |
+
return ChatbotData(root=processed_messages)
|
218 |
+
|
219 |
+
def example_inputs(self) -> Any:
|
220 |
+
return [["Hello!", None]]
|
src/backend/gradio_gptchatbot/gptchatbot.pyi
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# from pydantic import Field, TypeAdapter
|
18 |
+
|
19 |
+
set_documentation_group("component")
|
20 |
+
|
21 |
+
|
22 |
+
class FileMessage(GradioModel):
|
23 |
+
file: FileData
|
24 |
+
alt_text: Optional[str] = None
|
25 |
+
|
26 |
+
|
27 |
+
# _Message = Annotated[List[Union[str, FileMessage, None]], Field(min_length=2, max_length=2)]
|
28 |
+
|
29 |
+
# Message = TypeAdapter(_Message)
|
30 |
+
|
31 |
+
|
32 |
+
class ChatbotData(GradioRootModel):
|
33 |
+
root: List[Tuple[Union[str, FileMessage, None], Union[str, FileMessage, None]]]
|
34 |
+
|
35 |
+
from gradio.events import Dependency
|
36 |
+
|
37 |
+
@document()
|
38 |
+
class GPTChatbot(Component):
|
39 |
+
"""
|
40 |
+
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 GPTChatbot, and other kinds of files which are displayed as links.
|
41 |
+
Preprocessing: passes the messages in the GPTChatbot 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.
|
42 |
+
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 GPTChatbot, or (3) None, in which case the message is not displayed.
|
43 |
+
|
44 |
+
Demos: chatbot_simple, chatbot_multimodal
|
45 |
+
Guides: creating-a-chatbot
|
46 |
+
"""
|
47 |
+
|
48 |
+
EVENTS = [Events.change, Events.select, Events.like]
|
49 |
+
data_model = ChatbotData
|
50 |
+
|
51 |
+
def __init__(
|
52 |
+
self,
|
53 |
+
value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
|
54 |
+
| Callable
|
55 |
+
| None = None,
|
56 |
+
*,
|
57 |
+
label: str | None = None,
|
58 |
+
every: float | None = None,
|
59 |
+
show_label: bool | None = None,
|
60 |
+
container: bool = True,
|
61 |
+
scale: int | None = None,
|
62 |
+
min_width: int = 160,
|
63 |
+
visible: bool = True,
|
64 |
+
elem_id: str | None = None,
|
65 |
+
elem_classes: list[str] | str | None = None,
|
66 |
+
render: bool = True,
|
67 |
+
height: int | None = None,
|
68 |
+
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
69 |
+
rtl: bool = False,
|
70 |
+
show_share_button: bool | None = None,
|
71 |
+
show_copy_button: bool = False,
|
72 |
+
avatar_images: tuple[str | Path | None, str | Path | None] | None = None,
|
73 |
+
sanitize_html: bool = True,
|
74 |
+
render_markdown: bool = True,
|
75 |
+
bubble_full_width: bool = True,
|
76 |
+
line_breaks: bool = True,
|
77 |
+
likeable: bool = False,
|
78 |
+
layout: Literal["panel", "bubble"] | None = None,
|
79 |
+
):
|
80 |
+
"""
|
81 |
+
Parameters:
|
82 |
+
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.
|
83 |
+
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.
|
84 |
+
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.
|
85 |
+
show_label: if True, will display label.
|
86 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
87 |
+
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.
|
88 |
+
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.
|
89 |
+
visible: If False, component will be hidden.
|
90 |
+
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.
|
91 |
+
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.
|
92 |
+
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.
|
93 |
+
height: height of the component in pixels.
|
94 |
+
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).
|
95 |
+
rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
|
96 |
+
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.
|
97 |
+
show_copy_button: If True, will show a copy button for each chatbot message.
|
98 |
+
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.
|
99 |
+
sanitize_html: If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.
|
100 |
+
render_markdown: If False, will disable Markdown rendering for chatbot messages.
|
101 |
+
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.
|
102 |
+
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.
|
103 |
+
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.
|
104 |
+
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".
|
105 |
+
"""
|
106 |
+
self.likeable = likeable
|
107 |
+
self.height = height
|
108 |
+
self.rtl = rtl
|
109 |
+
if latex_delimiters is None:
|
110 |
+
latex_delimiters = [{"left": "$$", "right": "$$", "display": True}]
|
111 |
+
self.latex_delimiters = latex_delimiters
|
112 |
+
self.show_share_button = (
|
113 |
+
(utils.get_space() is not None)
|
114 |
+
if show_share_button is None
|
115 |
+
else show_share_button
|
116 |
+
)
|
117 |
+
self.render_markdown = render_markdown
|
118 |
+
self.show_copy_button = show_copy_button
|
119 |
+
self.sanitize_html = sanitize_html
|
120 |
+
self.bubble_full_width = bubble_full_width
|
121 |
+
self.line_breaks = line_breaks
|
122 |
+
self.layout = layout
|
123 |
+
super().__init__(
|
124 |
+
label=label,
|
125 |
+
every=every,
|
126 |
+
show_label=show_label,
|
127 |
+
container=container,
|
128 |
+
scale=scale,
|
129 |
+
min_width=min_width,
|
130 |
+
visible=visible,
|
131 |
+
elem_id=elem_id,
|
132 |
+
elem_classes=elem_classes,
|
133 |
+
render=render,
|
134 |
+
value=value,
|
135 |
+
)
|
136 |
+
self.avatar_images: list[str | None] = [None, None]
|
137 |
+
if avatar_images is None:
|
138 |
+
pass
|
139 |
+
else:
|
140 |
+
self.avatar_images = [
|
141 |
+
processing_utils.move_resource_to_block_cache(avatar_images[0], self),
|
142 |
+
processing_utils.move_resource_to_block_cache(avatar_images[1], self),
|
143 |
+
]
|
144 |
+
|
145 |
+
def _preprocess_chat_messages(
|
146 |
+
self, chat_message: str | FileMessage | None
|
147 |
+
) -> str | tuple[str | None] | tuple[str | None, str] | None:
|
148 |
+
if chat_message is None:
|
149 |
+
return None
|
150 |
+
elif isinstance(chat_message, FileMessage):
|
151 |
+
if chat_message.alt_text is not None:
|
152 |
+
return (chat_message.file.path, chat_message.alt_text)
|
153 |
+
else:
|
154 |
+
return (chat_message.file.path,)
|
155 |
+
elif isinstance(chat_message, str):
|
156 |
+
return chat_message
|
157 |
+
else:
|
158 |
+
raise ValueError(f"Invalid message for GPTChatbot component: {chat_message}")
|
159 |
+
|
160 |
+
def preprocess(
|
161 |
+
self,
|
162 |
+
payload: ChatbotData,
|
163 |
+
) -> list[list[str | tuple[str] | tuple[str, str] | None]]:
|
164 |
+
if payload is None:
|
165 |
+
return payload
|
166 |
+
processed_messages = []
|
167 |
+
for message_pair in payload.root:
|
168 |
+
if not isinstance(message_pair, (tuple, list)):
|
169 |
+
raise TypeError(
|
170 |
+
f"Expected a list of lists or list of tuples. Received: {message_pair}"
|
171 |
+
)
|
172 |
+
if len(message_pair) != 2:
|
173 |
+
raise TypeError(
|
174 |
+
f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
|
175 |
+
)
|
176 |
+
processed_messages.append(
|
177 |
+
[
|
178 |
+
self._preprocess_chat_messages(message_pair[0]),
|
179 |
+
self._preprocess_chat_messages(message_pair[1]),
|
180 |
+
]
|
181 |
+
)
|
182 |
+
return processed_messages
|
183 |
+
|
184 |
+
def _postprocess_chat_messages(
|
185 |
+
self, chat_message: str | tuple | list | None
|
186 |
+
) -> str | FileMessage | None:
|
187 |
+
if chat_message is None:
|
188 |
+
return None
|
189 |
+
elif isinstance(chat_message, (tuple, list)):
|
190 |
+
filepath = str(chat_message[0])
|
191 |
+
|
192 |
+
mime_type = client_utils.get_mimetype(filepath)
|
193 |
+
return FileMessage(
|
194 |
+
file=FileData(path=filepath, mime_type=mime_type),
|
195 |
+
alt_text=chat_message[1] if len(chat_message) > 1 else None,
|
196 |
+
)
|
197 |
+
elif isinstance(chat_message, str):
|
198 |
+
chat_message = inspect.cleandoc(chat_message)
|
199 |
+
return chat_message
|
200 |
+
else:
|
201 |
+
raise ValueError(f"Invalid message for GPTChatbot component: {chat_message}")
|
202 |
+
|
203 |
+
def postprocess(
|
204 |
+
self,
|
205 |
+
value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple],
|
206 |
+
) -> ChatbotData:
|
207 |
+
if value is None:
|
208 |
+
return ChatbotData(root=[])
|
209 |
+
processed_messages = []
|
210 |
+
for message_pair in value:
|
211 |
+
if not isinstance(message_pair, (tuple, list)):
|
212 |
+
raise TypeError(
|
213 |
+
f"Expected a list of lists or list of tuples. Received: {message_pair}"
|
214 |
+
)
|
215 |
+
if len(message_pair) != 2:
|
216 |
+
raise TypeError(
|
217 |
+
f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
|
218 |
+
)
|
219 |
+
processed_messages.append(
|
220 |
+
[
|
221 |
+
self._postprocess_chat_messages(message_pair[0]),
|
222 |
+
self._postprocess_chat_messages(message_pair[1]),
|
223 |
+
]
|
224 |
+
)
|
225 |
+
return ChatbotData(root=processed_messages)
|
226 |
+
|
227 |
+
def example_inputs(self) -> Any:
|
228 |
+
return [["Hello!", None]]
|
229 |
+
|
230 |
+
|
231 |
+
def change(self,
|
232 |
+
fn: Callable | None,
|
233 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
234 |
+
outputs: Component | Sequence[Component] | None = None,
|
235 |
+
api_name: str | None | Literal[False] = None,
|
236 |
+
status_tracker: None = None,
|
237 |
+
scroll_to_output: bool = False,
|
238 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
239 |
+
queue: bool | None = None,
|
240 |
+
batch: bool = False,
|
241 |
+
max_batch_size: int = 4,
|
242 |
+
preprocess: bool = True,
|
243 |
+
postprocess: bool = True,
|
244 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
245 |
+
every: float | None = None,
|
246 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
247 |
+
js: str | None = None,) -> Dependency:
|
248 |
+
"""
|
249 |
+
Parameters:
|
250 |
+
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.
|
251 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
252 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
253 |
+
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.
|
254 |
+
scroll_to_output: If True, will scroll to output component on completion
|
255 |
+
show_progress: If True, will show progress animation while pending
|
256 |
+
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.
|
257 |
+
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.
|
258 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
259 |
+
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).
|
260 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
261 |
+
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.
|
262 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
263 |
+
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.
|
264 |
+
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.
|
265 |
+
"""
|
266 |
+
...
|
267 |
+
|
268 |
+
def select(self,
|
269 |
+
fn: Callable | None,
|
270 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
271 |
+
outputs: Component | Sequence[Component] | None = None,
|
272 |
+
api_name: str | None | Literal[False] = None,
|
273 |
+
status_tracker: None = None,
|
274 |
+
scroll_to_output: bool = False,
|
275 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
276 |
+
queue: bool | None = None,
|
277 |
+
batch: bool = False,
|
278 |
+
max_batch_size: int = 4,
|
279 |
+
preprocess: bool = True,
|
280 |
+
postprocess: bool = True,
|
281 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
282 |
+
every: float | None = None,
|
283 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
284 |
+
js: str | None = None,) -> Dependency:
|
285 |
+
"""
|
286 |
+
Parameters:
|
287 |
+
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.
|
288 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
289 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
290 |
+
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.
|
291 |
+
scroll_to_output: If True, will scroll to output component on completion
|
292 |
+
show_progress: If True, will show progress animation while pending
|
293 |
+
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.
|
294 |
+
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.
|
295 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
296 |
+
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).
|
297 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
298 |
+
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.
|
299 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
300 |
+
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.
|
301 |
+
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.
|
302 |
+
"""
|
303 |
+
...
|
304 |
+
|
305 |
+
def like(self,
|
306 |
+
fn: Callable | None,
|
307 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
308 |
+
outputs: Component | Sequence[Component] | None = None,
|
309 |
+
api_name: str | None | Literal[False] = None,
|
310 |
+
status_tracker: None = None,
|
311 |
+
scroll_to_output: bool = False,
|
312 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
313 |
+
queue: bool | None = None,
|
314 |
+
batch: bool = False,
|
315 |
+
max_batch_size: int = 4,
|
316 |
+
preprocess: bool = True,
|
317 |
+
postprocess: bool = True,
|
318 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
319 |
+
every: float | None = None,
|
320 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
321 |
+
js: str | None = None,) -> Dependency:
|
322 |
+
"""
|
323 |
+
Parameters:
|
324 |
+
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.
|
325 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
326 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
327 |
+
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.
|
328 |
+
scroll_to_output: If True, will scroll to output component on completion
|
329 |
+
show_progress: If True, will show progress animation while pending
|
330 |
+
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.
|
331 |
+
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.
|
332 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
333 |
+
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).
|
334 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
335 |
+
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.
|
336 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
337 |
+
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.
|
338 |
+
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.
|
339 |
+
"""
|
340 |
+
...
|
src/demo/__init__.py
ADDED
File without changes
|
src/demo/app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_gptchatbot import GPTChatbot
|
4 |
+
|
5 |
+
|
6 |
+
example = GPTChatbot().example_inputs()
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
with gr.Row():
|
10 |
+
GPTChatbot(label="Blank"), # blank component
|
11 |
+
GPTChatbot(value=example, label="Populated"), # populated component
|
12 |
+
|
13 |
+
|
14 |
+
demo.launch()
|
src/frontend/Index.svelte
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
15 |
+
export let elem_id = "";
|
16 |
+
export let elem_classes: string[] = [];
|
17 |
+
export let visible = true;
|
18 |
+
export let value: [
|
19 |
+
string | { file: FileData; alt_text: string | null } | null,
|
20 |
+
string | { file: FileData; alt_text: string | null } | null
|
21 |
+
][] = [];
|
22 |
+
export let scale: number | null = null;
|
23 |
+
export let min_width: number | undefined = undefined;
|
24 |
+
export let label: string;
|
25 |
+
export let show_label = true;
|
26 |
+
export let root: string;
|
27 |
+
export let proxy_url: null | string;
|
28 |
+
export let _selectable = false;
|
29 |
+
export let likeable = false;
|
30 |
+
export let show_share_button = false;
|
31 |
+
export let rtl = false;
|
32 |
+
export let show_copy_button = false;
|
33 |
+
export let sanitize_html = true;
|
34 |
+
export let bubble_full_width = true;
|
35 |
+
export let layout: "bubble" | "panel" = "bubble";
|
36 |
+
export let render_markdown = true;
|
37 |
+
export let line_breaks = true;
|
38 |
+
export let latex_delimiters: {
|
39 |
+
left: string;
|
40 |
+
right: string;
|
41 |
+
display: boolean;
|
42 |
+
}[];
|
43 |
+
export let gradio: Gradio<{
|
44 |
+
change: typeof value;
|
45 |
+
select: SelectData;
|
46 |
+
share: ShareData;
|
47 |
+
error: string;
|
48 |
+
like: LikeData;
|
49 |
+
}>;
|
50 |
+
export let avatar_images: [string | null, string | null] = [null, null];
|
51 |
+
|
52 |
+
let _value: [
|
53 |
+
string | { file: FileData; alt_text: string | null } | null,
|
54 |
+
string | { file: FileData; alt_text: string | null } | null
|
55 |
+
][];
|
56 |
+
|
57 |
+
const redirect_src_url = (src: string): string =>
|
58 |
+
src.replace('src="/file', `src="${root}file`);
|
59 |
+
|
60 |
+
function normalize_messages(
|
61 |
+
message: { file: FileData; alt_text: string | null } | null
|
62 |
+
): { file: FileData; alt_text: string | null } | null {
|
63 |
+
if (message === null) {
|
64 |
+
return message;
|
65 |
+
}
|
66 |
+
return {
|
67 |
+
file: normalise_file(message?.file, root, proxy_url) as FileData,
|
68 |
+
alt_text: message?.alt_text
|
69 |
+
};
|
70 |
+
}
|
71 |
+
|
72 |
+
$: _value = value
|
73 |
+
? value.map(([user_msg, bot_msg]) => [
|
74 |
+
typeof user_msg === "string"
|
75 |
+
? redirect_src_url(user_msg)
|
76 |
+
: normalize_messages(user_msg),
|
77 |
+
typeof bot_msg === "string"
|
78 |
+
? redirect_src_url(bot_msg)
|
79 |
+
: normalize_messages(bot_msg)
|
80 |
+
])
|
81 |
+
: [];
|
82 |
+
|
83 |
+
export let loading_status: LoadingStatus | undefined = undefined;
|
84 |
+
export let height = 400;
|
85 |
+
</script>
|
86 |
+
|
87 |
+
<Block
|
88 |
+
{elem_id}
|
89 |
+
{elem_classes}
|
90 |
+
{visible}
|
91 |
+
padding={false}
|
92 |
+
{scale}
|
93 |
+
{min_width}
|
94 |
+
{height}
|
95 |
+
allow_overflow={false}
|
96 |
+
>
|
97 |
+
{#if loading_status}
|
98 |
+
<StatusTracker
|
99 |
+
autoscroll={gradio.autoscroll}
|
100 |
+
i18n={gradio.i18n}
|
101 |
+
{...loading_status}
|
102 |
+
show_progress={loading_status.show_progress === "hidden"
|
103 |
+
? "hidden"
|
104 |
+
: "minimal"}
|
105 |
+
/>
|
106 |
+
{/if}
|
107 |
+
<div class="wrapper">
|
108 |
+
{#if show_label}
|
109 |
+
<BlockLabel
|
110 |
+
{show_label}
|
111 |
+
Icon={Chat}
|
112 |
+
float={false}
|
113 |
+
label={label || "Chatbot"}
|
114 |
+
/>
|
115 |
+
{/if}
|
116 |
+
<ChatBot
|
117 |
+
i18n={gradio.i18n}
|
118 |
+
selectable={_selectable}
|
119 |
+
{likeable}
|
120 |
+
{show_share_button}
|
121 |
+
value={_value}
|
122 |
+
{latex_delimiters}
|
123 |
+
{render_markdown}
|
124 |
+
pending_message={loading_status?.status === "pending"}
|
125 |
+
{rtl}
|
126 |
+
{show_copy_button}
|
127 |
+
on:change={() => gradio.dispatch("change", value)}
|
128 |
+
on:select={(e) => gradio.dispatch("select", e.detail)}
|
129 |
+
on:like={(e) => gradio.dispatch("like", e.detail)}
|
130 |
+
on:share={(e) => gradio.dispatch("share", e.detail)}
|
131 |
+
on:error={(e) => gradio.dispatch("error", e.detail)}
|
132 |
+
{avatar_images}
|
133 |
+
{sanitize_html}
|
134 |
+
{bubble_full_width}
|
135 |
+
{line_breaks}
|
136 |
+
{layout}
|
137 |
+
{proxy_url}
|
138 |
+
{root}
|
139 |
+
/>
|
140 |
+
</div>
|
141 |
+
</Block>
|
142 |
+
|
143 |
+
<style>
|
144 |
+
.wrapper {
|
145 |
+
display: flex;
|
146 |
+
position: relative;
|
147 |
+
flex-direction: column;
|
148 |
+
align-items: start;
|
149 |
+
width: 100%;
|
150 |
+
height: 100%;
|
151 |
+
}
|
152 |
+
</style>
|
src/frontend/package-lock.json
ADDED
@@ -0,0 +1,1096 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_gptchatbot",
|
3 |
+
"version": "0.4.5",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "gradio_gptchatbot",
|
9 |
+
"version": "0.4.5",
|
10 |
+
"license": "ISC",
|
11 |
+
"dependencies": {
|
12 |
+
"@gradio/atoms": "0.2.1",
|
13 |
+
"@gradio/client": "0.8.1",
|
14 |
+
"@gradio/icons": "0.2.0",
|
15 |
+
"@gradio/markdown": "0.3.1",
|
16 |
+
"@gradio/statustracker": "0.3.1",
|
17 |
+
"@gradio/theme": "0.2.0",
|
18 |
+
"@gradio/upload": "0.4.1",
|
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.1",
|
415 |
+
"resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.2.1.tgz",
|
416 |
+
"integrity": "sha512-di3kKSbjxKGngvTAaqUaA6whOVs5BFlQULlWDPq1m37VRgUD7Oq2MkIE+T+YiNAhByN93pqA0hGrWwAUUuxy5Q==",
|
417 |
+
"dependencies": {
|
418 |
+
"@gradio/icons": "^0.2.0",
|
419 |
+
"@gradio/utils": "^0.2.0"
|
420 |
+
}
|
421 |
+
},
|
422 |
+
"node_modules/@gradio/client": {
|
423 |
+
"version": "0.8.1",
|
424 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.8.1.tgz",
|
425 |
+
"integrity": "sha512-qMFINw6MbubLYQiLorwGhyapH7bUSthH+7tevGgKOPuQWoW5TliPi95VEFRUQ+d2Y/vXqWj0+hubO94RO7v/7w==",
|
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.1",
|
447 |
+
"resolved": "https://registry.npmjs.org/@gradio/markdown/-/markdown-0.3.1.tgz",
|
448 |
+
"integrity": "sha512-rS5vs+KY/q51QiefzveuZOvR7Dl6qsNlMRA8Z/DJ2HBMum1Pz/ntQNVFxBGxNgh9nMW+EFNS1Ey2hAjKFeHMeA==",
|
449 |
+
"dependencies": {
|
450 |
+
"@gradio/atoms": "^0.2.1",
|
451 |
+
"@gradio/statustracker": "^0.3.1",
|
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.1",
|
465 |
+
"resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.3.1.tgz",
|
466 |
+
"integrity": "sha512-ZpmXZSnbgoFU2J54SrNntwfo2OEuEoRV310Q0zGVTH1VL7loziR7GuYhfIbgS8qFlrWM0MhMoLGDX+k7LAig5w==",
|
467 |
+
"dependencies": {
|
468 |
+
"@gradio/atoms": "^0.2.1",
|
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.4.1",
|
481 |
+
"resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.4.1.tgz",
|
482 |
+
"integrity": "sha512-iXEckwathXVCDRX+Jrnc6Qu5MDK108niej9p190V7+/B3+vjjP1eCBAd881zH7JR3VHthUBjNVu5/uXZ9cVX1A==",
|
483 |
+
"dependencies": {
|
484 |
+
"@gradio/atoms": "^0.2.1",
|
485 |
+
"@gradio/client": "^0.8.1",
|
486 |
+
"@gradio/icons": "^0.2.0",
|
487 |
+
"@gradio/upload": "^0.4.1",
|
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.7",
|
898 |
+
"resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.0.7.tgz",
|
899 |
+
"integrity": "sha512-3IjgV879kEihgjWwVv8HGDkyuKDyR8hssDEjMUAH5LNVhIcZge+u6UKhxPA+daEVMVZeKEHo5gWrLVlLPF1m3g==",
|
900 |
+
"peerDependencies": {
|
901 |
+
"marked": ">=4 <11"
|
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.3",
|
997 |
+
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.3.tgz",
|
998 |
+
"integrity": "sha512-sqmG9KC6uUc7fb3ZuWoxXvqk6MI9Uu4ABA1M0fYDgTlFYu1k02xp96u6U9+yJZiVm84m9zge7rrA/BNZdFpOKw==",
|
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_gptchatbot",
|
3 |
+
"version": "0.4.5",
|
4 |
+
"description": "Gradio UI packages",
|
5 |
+
"type": "module",
|
6 |
+
"author": "",
|
7 |
+
"license": "ISC",
|
8 |
+
"private": false,
|
9 |
+
"dependencies": {
|
10 |
+
"@gradio/atoms": "0.2.1",
|
11 |
+
"@gradio/client": "0.8.1",
|
12 |
+
"@gradio/icons": "0.2.0",
|
13 |
+
"@gradio/markdown": "0.3.1",
|
14 |
+
"@gradio/statustracker": "0.3.1",
|
15 |
+
"@gradio/theme": "0.2.0",
|
16 |
+
"@gradio/upload": "0.4.1",
|
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 { copy } from "@gradio/utils";
|
4 |
+
|
5 |
+
import { dequal } from "dequal/lite";
|
6 |
+
import { beforeUpdate, afterUpdate, createEventDispatcher } from "svelte";
|
7 |
+
import { ShareButton } from "@gradio/atoms";
|
8 |
+
import type { SelectData, LikeData } from "@gradio/utils";
|
9 |
+
import { MarkdownCode as Markdown } from "@gradio/markdown";
|
10 |
+
import { get_fetchable_url_or_file, type FileData } from "@gradio/client";
|
11 |
+
import Copy from "./Copy.svelte";
|
12 |
+
import type { I18nFormatter } from "js/app/src/gradio_helper";
|
13 |
+
import LikeDislike from "./LikeDislike.svelte";
|
14 |
+
import Pending from "./Pending.svelte";
|
15 |
+
|
16 |
+
export let value:
|
17 |
+
| [
|
18 |
+
string | { file: FileData; alt_text: string | null } | null,
|
19 |
+
string | { file: FileData; alt_text: string | null } | null
|
20 |
+
][]
|
21 |
+
| null;
|
22 |
+
let old_value:
|
23 |
+
| [
|
24 |
+
string | { file: FileData; alt_text: string | null } | null,
|
25 |
+
string | { file: FileData; alt_text: string | null } | null
|
26 |
+
][]
|
27 |
+
| null = null;
|
28 |
+
export let latex_delimiters: {
|
29 |
+
left: string;
|
30 |
+
right: string;
|
31 |
+
display: boolean;
|
32 |
+
}[];
|
33 |
+
export let pending_message = false;
|
34 |
+
export let selectable = false;
|
35 |
+
export let likeable = false;
|
36 |
+
export let show_share_button = false;
|
37 |
+
export let rtl = false;
|
38 |
+
export let show_copy_button = false;
|
39 |
+
export let avatar_images: [string | null, string | null] = [null, null];
|
40 |
+
export let sanitize_html = true;
|
41 |
+
export let bubble_full_width = true;
|
42 |
+
export let render_markdown = true;
|
43 |
+
export let line_breaks = true;
|
44 |
+
export let root: string;
|
45 |
+
export let proxy_url: null | string;
|
46 |
+
export let i18n: I18nFormatter;
|
47 |
+
export let layout: "bubble" | "panel" = "bubble";
|
48 |
+
|
49 |
+
let div: HTMLDivElement;
|
50 |
+
let autoscroll: boolean;
|
51 |
+
|
52 |
+
const dispatch = createEventDispatcher<{
|
53 |
+
change: undefined;
|
54 |
+
select: SelectData;
|
55 |
+
like: LikeData;
|
56 |
+
}>();
|
57 |
+
|
58 |
+
beforeUpdate(() => {
|
59 |
+
autoscroll =
|
60 |
+
div && div.offsetHeight + div.scrollTop > div.scrollHeight - 100;
|
61 |
+
});
|
62 |
+
|
63 |
+
const scroll = (): void => {
|
64 |
+
if (autoscroll) {
|
65 |
+
div.scrollTo(0, div.scrollHeight);
|
66 |
+
}
|
67 |
+
};
|
68 |
+
afterUpdate(() => {
|
69 |
+
if (autoscroll) {
|
70 |
+
scroll();
|
71 |
+
div.querySelectorAll("img").forEach((n) => {
|
72 |
+
n.addEventListener("load", () => {
|
73 |
+
scroll();
|
74 |
+
});
|
75 |
+
});
|
76 |
+
}
|
77 |
+
});
|
78 |
+
|
79 |
+
$: {
|
80 |
+
if (!dequal(value, old_value)) {
|
81 |
+
old_value = value;
|
82 |
+
dispatch("change");
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
function handle_select(
|
87 |
+
i: number,
|
88 |
+
j: number,
|
89 |
+
message: string | { file: FileData; alt_text: string | null } | null
|
90 |
+
): void {
|
91 |
+
dispatch("select", {
|
92 |
+
index: [i, j],
|
93 |
+
value: message
|
94 |
+
});
|
95 |
+
}
|
96 |
+
|
97 |
+
function handle_like(
|
98 |
+
i: number,
|
99 |
+
j: number,
|
100 |
+
message: string | { file: FileData; alt_text: string | null } | null,
|
101 |
+
liked: boolean
|
102 |
+
): void {
|
103 |
+
dispatch("like", {
|
104 |
+
index: [i, j],
|
105 |
+
value: message,
|
106 |
+
liked: liked
|
107 |
+
});
|
108 |
+
}
|
109 |
+
</script>
|
110 |
+
|
111 |
+
{#if show_share_button && value !== null && value.length > 0}
|
112 |
+
<div class="share-button">
|
113 |
+
<ShareButton
|
114 |
+
{i18n}
|
115 |
+
on:error
|
116 |
+
on:share
|
117 |
+
formatter={format_chat_for_sharing}
|
118 |
+
{value}
|
119 |
+
/>
|
120 |
+
</div>
|
121 |
+
{/if}
|
122 |
+
|
123 |
+
<div
|
124 |
+
class={layout === "bubble" ? "bubble-wrap" : "panel-wrap"}
|
125 |
+
bind:this={div}
|
126 |
+
role="log"
|
127 |
+
aria-label="chatbot conversation"
|
128 |
+
aria-live="polite"
|
129 |
+
>
|
130 |
+
<div class="message-wrap" class:bubble-gap={layout === "bubble"} use:copy>
|
131 |
+
{#if value !== null}
|
132 |
+
{#each value as message_pair, i}
|
133 |
+
{#each message_pair as message, j}
|
134 |
+
{#if message !== null}
|
135 |
+
<div class="message-row {layout} {j == 0 ? 'user-row' : 'bot-row'}">
|
136 |
+
{#if avatar_images[j] !== null}
|
137 |
+
<div class="avatar-container">
|
138 |
+
<img
|
139 |
+
class="avatar-image"
|
140 |
+
src={get_fetchable_url_or_file(
|
141 |
+
avatar_images[j],
|
142 |
+
root,
|
143 |
+
proxy_url
|
144 |
+
)}
|
145 |
+
alt="{j == 0 ? 'user' : 'bot'} avatar"
|
146 |
+
/>
|
147 |
+
</div>
|
148 |
+
{/if}
|
149 |
+
|
150 |
+
<div
|
151 |
+
class="message {j == 0 ? 'user' : 'bot'}"
|
152 |
+
class:message-fit={layout === "bubble" && !bubble_full_width}
|
153 |
+
class:panel-full-width={layout === "panel"}
|
154 |
+
class:message-bubble-border={layout === "bubble"}
|
155 |
+
class:message-markdown-disabled={!render_markdown}
|
156 |
+
>
|
157 |
+
<button
|
158 |
+
data-testid={j == 0 ? "user" : "bot"}
|
159 |
+
class:latest={i === value.length - 1}
|
160 |
+
class:message-markdown-disabled={!render_markdown}
|
161 |
+
style:user-select="text"
|
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 |
+
{#if typeof message === "string"}
|
176 |
+
<Markdown
|
177 |
+
{message}
|
178 |
+
{latex_delimiters}
|
179 |
+
{sanitize_html}
|
180 |
+
{render_markdown}
|
181 |
+
{line_breaks}
|
182 |
+
on:load={scroll}
|
183 |
+
/>
|
184 |
+
{:else if message !== null && message.file?.mime_type?.includes("audio")}
|
185 |
+
<audio
|
186 |
+
data-testid="chatbot-audio"
|
187 |
+
controls
|
188 |
+
preload="metadata"
|
189 |
+
src={message.file?.url}
|
190 |
+
title={message.alt_text}
|
191 |
+
on:play
|
192 |
+
on:pause
|
193 |
+
on:ended
|
194 |
+
/>
|
195 |
+
{:else if message !== null && message.file?.mime_type?.includes("video")}
|
196 |
+
<video
|
197 |
+
data-testid="chatbot-video"
|
198 |
+
controls
|
199 |
+
src={message.file?.url}
|
200 |
+
title={message.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 && message.file?.mime_type?.includes("image")}
|
209 |
+
<img
|
210 |
+
data-testid="chatbot-image"
|
211 |
+
src={message.file?.url}
|
212 |
+
alt={message.alt_text}
|
213 |
+
/>
|
214 |
+
{:else if message !== null && message.file?.url !== null}
|
215 |
+
<a
|
216 |
+
data-testid="chatbot-file"
|
217 |
+
href={message.file?.url}
|
218 |
+
target="_blank"
|
219 |
+
download={window.__is_colab__
|
220 |
+
? null
|
221 |
+
: message.file?.orig_name || message.file?.path}
|
222 |
+
>
|
223 |
+
{message.file?.orig_name || message.file?.path}
|
224 |
+
</a>
|
225 |
+
{/if}
|
226 |
+
</button>
|
227 |
+
</div>
|
228 |
+
{#if (likeable && j !== 0) || (show_copy_button && message && typeof message === "string")}
|
229 |
+
<div
|
230 |
+
class="message-buttons-{j == 0
|
231 |
+
? 'user'
|
232 |
+
: 'bot'} message-buttons-{layout} {avatar_images[j] !==
|
233 |
+
null && 'with-avatar'}"
|
234 |
+
class:message-buttons-fit={layout === "bubble" &&
|
235 |
+
!bubble_full_width}
|
236 |
+
class:bubble-buttons-user={layout === "bubble"}
|
237 |
+
>
|
238 |
+
{#if likeable && j == 1}
|
239 |
+
<LikeDislike
|
240 |
+
action="like"
|
241 |
+
handle_action={() => handle_like(i, j, message, true)}
|
242 |
+
/>
|
243 |
+
<LikeDislike
|
244 |
+
action="dislike"
|
245 |
+
handle_action={() => handle_like(i, j, message, false)}
|
246 |
+
/>
|
247 |
+
{/if}
|
248 |
+
{#if show_copy_button && message && typeof message === "string"}
|
249 |
+
<Copy value={message} />
|
250 |
+
{/if}
|
251 |
+
</div>
|
252 |
+
{/if}
|
253 |
+
</div>
|
254 |
+
{/if}
|
255 |
+
{/each}
|
256 |
+
{/each}
|
257 |
+
{#if pending_message}
|
258 |
+
<Pending {layout} />
|
259 |
+
{/if}
|
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,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(--color-accent-soft);
|
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: var(--size-16);
|
31 |
+
}
|
32 |
+
.dot-flashing {
|
33 |
+
animation: flash 1s infinite ease-in-out;
|
34 |
+
border-radius: 5px;
|
35 |
+
background-color: var(--body-text-color);
|
36 |
+
width: 7px;
|
37 |
+
height: 7px;
|
38 |
+
color: var(--body-text-color);
|
39 |
+
}
|
40 |
+
@keyframes flash {
|
41 |
+
0%,
|
42 |
+
100% {
|
43 |
+
opacity: 0;
|
44 |
+
}
|
45 |
+
50% {
|
46 |
+
opacity: 1;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
.dot-flashing:nth-child(1) {
|
51 |
+
animation-delay: 0s;
|
52 |
+
}
|
53 |
+
|
54 |
+
.dot-flashing:nth-child(2) {
|
55 |
+
animation-delay: 0.33s;
|
56 |
+
}
|
57 |
+
.dot-flashing:nth-child(3) {
|
58 |
+
animation-delay: 0.66s;
|
59 |
+
}
|
60 |
+
</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,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { FileData } from "@gradio/client";
|
2 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
3 |
+
|
4 |
+
export const format_chat_for_sharing = async (
|
5 |
+
chat: [string | FileData | null, string | FileData | null][]
|
6 |
+
): Promise<string> => {
|
7 |
+
let messages = await Promise.all(
|
8 |
+
chat.map(async (message_pair) => {
|
9 |
+
return await Promise.all(
|
10 |
+
message_pair.map(async (message, i) => {
|
11 |
+
if (message === null) return "";
|
12 |
+
let speaker_emoji = i === 0 ? "😃" : "🤖";
|
13 |
+
let html_content = "";
|
14 |
+
|
15 |
+
if (typeof message === "string") {
|
16 |
+
const regexPatterns = {
|
17 |
+
audio: /<audio.*?src="(\/file=.*?)"/g,
|
18 |
+
video: /<video.*?src="(\/file=.*?)"/g,
|
19 |
+
image: /<img.*?src="(\/file=.*?)".*?\/>|!\[.*?\]\((\/file=.*?)\)/g
|
20 |
+
};
|
21 |
+
|
22 |
+
html_content = message;
|
23 |
+
|
24 |
+
for (let [_, regex] of Object.entries(regexPatterns)) {
|
25 |
+
let match;
|
26 |
+
|
27 |
+
while ((match = regex.exec(message)) !== null) {
|
28 |
+
const fileUrl = match[1] || match[2];
|
29 |
+
const newUrl = await uploadToHuggingFace(fileUrl, "url");
|
30 |
+
html_content = html_content.replace(fileUrl, newUrl);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
} else {
|
34 |
+
if (!message?.url) return "";
|
35 |
+
const file_url = await uploadToHuggingFace(message.url, "url");
|
36 |
+
if (message.mime_type?.includes("audio")) {
|
37 |
+
html_content = `<audio controls src="${file_url}"></audio>`;
|
38 |
+
} else if (message.mime_type?.includes("video")) {
|
39 |
+
html_content = file_url;
|
40 |
+
} else if (message.mime_type?.includes("image")) {
|
41 |
+
html_content = `<img src="${file_url}" />`;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
return `${speaker_emoji}: ${html_content}`;
|
46 |
+
})
|
47 |
+
);
|
48 |
+
})
|
49 |
+
);
|
50 |
+
return messages
|
51 |
+
.map((message_pair) =>
|
52 |
+
message_pair.join(
|
53 |
+
message_pair[0] !== "" && message_pair[1] !== "" ? "\n" : ""
|
54 |
+
)
|
55 |
+
)
|
56 |
+
.join("\n");
|
57 |
+
};
|
src/pyproject.toml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_gptchatbot"
|
11 |
+
version = "0.0.1"
|
12 |
+
description = "a GPT-style Chatbot component"
|
13 |
+
readme = "README.md"
|
14 |
+
license = "MIT"
|
15 |
+
requires-python = ">=3.8"
|
16 |
+
authors = [{ name = "YOUR NAME", email = "[email protected]" }]
|
17 |
+
keywords = ["gradio-custom-component", "gradio-template-Chatbot", "chatbot"]
|
18 |
+
# Add dependencies here
|
19 |
+
dependencies = ["gradio>=4.0,<5.0"]
|
20 |
+
classifiers = [
|
21 |
+
'Development Status :: 3 - Alpha',
|
22 |
+
'License :: OSI Approved :: Apache Software License',
|
23 |
+
'Operating System :: OS Independent',
|
24 |
+
'Programming Language :: Python :: 3',
|
25 |
+
'Programming Language :: Python :: 3 :: Only',
|
26 |
+
'Programming Language :: Python :: 3.8',
|
27 |
+
'Programming Language :: Python :: 3.9',
|
28 |
+
'Programming Language :: Python :: 3.10',
|
29 |
+
'Programming Language :: Python :: 3.11',
|
30 |
+
'Topic :: Scientific/Engineering',
|
31 |
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
32 |
+
'Topic :: Scientific/Engineering :: Visualization',
|
33 |
+
]
|
34 |
+
|
35 |
+
[project.optional-dependencies]
|
36 |
+
dev = ["build", "twine"]
|
37 |
+
|
38 |
+
[tool.hatch.build]
|
39 |
+
artifacts = ["/backend/gradio_gptchatbot/templates", "*.pyi"]
|
40 |
+
|
41 |
+
[tool.hatch.build.targets.wheel]
|
42 |
+
packages = ["/backend/gradio_gptchatbot"]
|