Jedijamez commited on
Commit
1fa7a3d
1 Parent(s): 747dda0

Upload folder using huggingface_hub

Browse files
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", "space.py"]
README.md CHANGED
@@ -1,10 +1,17 @@
 
1
  ---
2
- title: Gradio Awsbr Mmchatbot
3
- emoji: 🏢
4
- colorFrom: pink
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
1
+
2
  ---
3
+ tags: [gradio-custom-component,gradio-template-Chatbot,AWS,Bedrock,Amazon Bedrock,Anthropic,LLM,Chatbot,Multimodal,Claude,Claude v3]
4
+ title: gradio_awsbr_mmchatbot V0.0.2
5
+ colorFrom: blue
6
+ colorTo: red
7
  sdk: docker
8
  pinned: false
9
+ license: apache-2.0
10
  ---
11
 
12
+
13
+ # Name: gradio_awsbr_mmchatbot
14
+
15
+ Description: This component enables multi-modal input for the Anthropic Claude v3 suite of models available from Amazon Bedrock
16
+
17
+ Install with: pip install gradio_awsbr_mmchatbot
__init__.py ADDED
File without changes
__pycache__/__init__.cpython-310.pyc ADDED
Binary file (175 Bytes). View file
 
__pycache__/app.cpython-310.pyc ADDED
Binary file (1.67 kB). View file
 
__pycache__/bedrock_utils.cpython-310.pyc ADDED
Binary file (1.61 kB). View file
 
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_awsbr_mmchatbot import MultiModalChatbot
3
+ from gradio.data_classes import FileData
4
+ from bedrock_utils import MultimodalInputHandler
5
+
6
+
7
+ # A function to call the multi-modal input for Anthropic Claude v3 sonnet using Bedrock boto3
8
+ async def get_response(text, file):
9
+ # If there is a file uploaded, then we will send it to Anthropic Claude v3 sonnet.
10
+ # If there is no file uploaded, then we will send the text to Anthropic Claude v3 sonnet.
11
+ try:
12
+ userMsg = {
13
+ "text": text,
14
+ "files": [{"file": FileData(path=file)}]
15
+ }
16
+ except:
17
+ userMsg = {
18
+ "text": text,
19
+ "files": []
20
+ }
21
+ # Define a variable to store the response from the Anthropic Claude v3 sonnet
22
+ llmResponse = ""
23
+ handler = MultimodalInputHandler(text, file)
24
+ # Loop through the response from Anthropic Claude v3 sonnet, and append it to our llmResponse variable.
25
+ async for x in handler.handleInput():
26
+ llmResponse += x
27
+ yield [[userMsg, {"text": llmResponse, "files": []}]]
28
+ # Yield the response from Anthropic Claude v3 sonnet. This is unecessary as we can just yield the llmResponse variable in an iterative fashion as above.
29
+ # But just in case.... let's yield the entire response object as well and overwrite the messages in the Chatbot.
30
+ response = {
31
+ "text": llmResponse,
32
+ "files": []
33
+ }
34
+ yield [[userMsg, response]]
35
+
36
+ # Defining Gradio Interface using Blocks Structure
37
+ with gr.Blocks() as demo:
38
+ # Give it a Title
39
+ gr.Markdown("## Gradio - MultiModal Chatbot")
40
+ # Define the Chat Tab
41
+ with gr.Tab(label="Chat"):
42
+ with gr.Row():
43
+ with gr.Column(scale=3):
44
+ # Set a variable equal to our MultiModalChatBot class
45
+ chatBot = MultiModalChatbot(height=700, render_markdown=True, bubble_full_width=True)
46
+ with gr.Row():
47
+ with gr.Column(scale=3):
48
+ # Set a variable equal to our user message
49
+ msg = gr.Textbox(placeholder='What is the meaning of life?', show_label=False)
50
+ with gr.Column(scale=1):
51
+ # Set a variable equal to our file upload
52
+ fileInput = gr.File(label="Upload Files")
53
+ with gr.Column(scale=1):
54
+ # Define our submit button and invoke our 'get_response' function when it's clicked.
55
+ gr.Button('Submit', variant='primary').click(get_response, inputs=[msg,fileInput], outputs=chatBot)
56
+ # Same function as above, but with the 'enter' key being pressed inside the gr.Textbox() component instead of the 'submit' button.
57
+ msg.submit(get_response, inputs=[msg, fileInput], outputs=chatBot)
58
+
59
+
60
+ if __name__ == '__main__':
61
+ demo.queue().launch()
bedrock_utils.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import base64
3
+ import os
4
+ from anthropic import AnthropicBedrock
5
+ from PIL import Image
6
+
7
+ class MultimodalInputHandler:
8
+ def __init__(self, text, image=None):
9
+ self.text = text
10
+ self.image = image
11
+
12
+ self.client = AnthropicBedrock(
13
+ aws_region='us-west-2'
14
+ )
15
+
16
+ async def handleInput(self):
17
+ if self.image:
18
+
19
+ # Determine the format of the image
20
+ if self.image.endswith(".jpg"):
21
+ formatType = "image/jpeg"
22
+ elif self.image.endswith(".png"):
23
+ formatType = "image/png"
24
+ elif self.image.endswith(".gif"):
25
+ formatType = "image/gif"
26
+ elif self.image.endswith(".webp"):
27
+ formatType = "image/webp"
28
+
29
+ # Encode the image as base64
30
+ b64EncodedImage = base64.b64encode(open(self.image, "rb").read())
31
+
32
+ # Send the image and text to the Anthropic API
33
+ with self.client.messages.stream(
34
+ model="anthropic.claude-3-sonnet-20240229-v1:0",
35
+ max_tokens=5000,
36
+ messages=[{
37
+ 'role': 'user',
38
+ 'content': [
39
+ {
40
+ "type": "image",
41
+ "source": {
42
+ "type": "base64",
43
+ "media_type": formatType,
44
+ "data": b64EncodedImage.decode("utf-8")
45
+ }
46
+ },
47
+ {
48
+ "type": "text",
49
+ "text": self.text
50
+ }
51
+ ]
52
+ }]
53
+ ) as stream:
54
+ for text in stream.text_stream:
55
+ yield text
56
+ else:
57
+ # Send the text to the Anthropic API
58
+ with self.client.messages.stream(
59
+ model="anthropic.claude-3-sonnet-20240229-v1:0",
60
+ max_tokens=5000,
61
+ messages=[{
62
+ 'role': 'user',
63
+ 'content': self.text
64
+ }]
65
+ ) as stream:
66
+ for text in stream.text_stream:
67
+ yield text
68
+
69
+ # MultimodalInputHandler = MultimodalInputHandler("What is this image?", "path/to/my/file")
70
+ # print(MultimodalInputHandler.handleInput())
css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_awsbr_mmchatbot==0.0.1
space.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'MultiModalChatbot': {'description': 'Creates a chatbot that displays user-submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables.\nAlso supports audio/video/image files, which are displayed in the MultiModalChatbot, and other kinds of files which are displayed as links. This\ncomponent is usually used as an output component.\n', 'members': {'__init__': {'value': {'type': 'list[\n list[\n str\n | tuple[str]\n | tuple[str | pathlib.Path, str]\n | None\n ]\n ]\n | Callable\n | None', 'default': 'None', 'description': '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.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': '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.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': '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.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': '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.'}, 'render': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'height': {'type': 'int | str | None', 'default': 'None', 'description': 'The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed.'}, 'latex_delimiters': {'type': 'list[dict[str, str | bool]] | None', 'default': 'None', 'description': '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).'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': '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.'}, 'show_copy_button': {'type': 'bool', 'default': 'False', 'description': 'If True, will show a copy button for each chatbot message.'}, 'avatar_images': {'type': 'tuple[\n str | pathlib.Path | None, str | pathlib.Path | None\n ]\n | None', 'default': 'None', 'description': '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.'}, 'sanitize_html': {'type': 'bool', 'default': 'True', 'description': 'If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.'}, 'render_markdown': {'type': 'bool', 'default': 'True', 'description': 'If False, will disable Markdown rendering for chatbot messages.'}, 'bubble_full_width': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'line_breaks': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'likeable': {'type': 'bool', 'default': 'False', 'description': '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.'}, 'layout': {'type': '"panel" | "bubble" | None', 'default': 'None', 'description': '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".'}}, 'postprocess': {'value': {'type': 'list[\n list[str | tuple[str] | tuple[str, str] | None]\n | tuple\n ]\n | None', 'description': 'expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.'}}, 'preprocess': {'return': {'type': 'list[MultimodalMessage] | None', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the MultiModalChatbot changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the MultiModalChatbot. Uses event data gradio.SelectData to carry `value` referring to the label of the MultiModalChatbot, and `selected` to refer to state of the MultiModalChatbot. See EventData documentation on how to use this event data'}, 'like': {'type': None, 'default': None, 'description': 'This listener is triggered when the user likes/dislikes from within the MultiModalChatbot. This event has EventData of type gradio.LikeData that carries information, accessible through LikeData.index and LikeData.value. See EventData documentation on how to use this event data.'}}}, '__meta__': {'additional_interfaces': {'MultimodalMessage': {'source': 'class MultimodalMessage(GradioModel):\n text: Optional[str] = None\n files: Optional[List[FileMessage]] = None', 'refs': ['FileMessage']}, 'FileMessage': {'source': 'class FileMessage(GradioModel):\n file: FileData\n alt_text: Optional[str] = None'}}, 'user_fn_refs': {'MultiModalChatbot': ['MultimodalMessage']}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_awsbr_mmchatbot`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_awsbr_mmchatbot/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_awsbr_mmchatbot"></a>
25
+ </div>
26
+
27
+ This component enables multi-modal input for the Anthropic Claude v3 suite of models available from Amazon Bedrock
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_awsbr_mmchatbot
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ import gradio as gr
42
+ from gradio_awsbr_mmchatbot import MultiModalChatbot
43
+ from gradio.data_classes import FileData
44
+ from bedrock_utils import MultimodalInputHandler
45
+
46
+
47
+ # A function to call the multi-modal input for Anthropic Claude v3 sonnet using Bedrock boto3
48
+ async def get_response(text, file):
49
+ # If there is a file uploaded, then we will send it to Anthropic Claude v3 sonnet.
50
+ # If there is no file uploaded, then we will send the text to Anthropic Claude v3 sonnet.
51
+ try:
52
+ userMsg = {
53
+ "text": text,
54
+ "files": [{"file": FileData(path=file)}]
55
+ }
56
+ except:
57
+ userMsg = {
58
+ "text": text,
59
+ "files": []
60
+ }
61
+ # Define a variable to store the response from the Anthropic Claude v3 sonnet
62
+ llmResponse = ""
63
+ handler = MultimodalInputHandler(text, file)
64
+ # Loop through the response from Anthropic Claude v3 sonnet, and append it to our llmResponse variable.
65
+ async for x in handler.handleInput():
66
+ llmResponse += x
67
+ yield [[userMsg, {"text": llmResponse, "files": []}]]
68
+ # Yield the response from Anthropic Claude v3 sonnet. This is unecessary as we can just yield the llmResponse variable in an iterative fashion as above.
69
+ # But just in case.... let's yield the entire response object as well and overwrite the messages in the Chatbot.
70
+ response = {
71
+ "text": llmResponse,
72
+ "files": []
73
+ }
74
+ yield [[userMsg, response]]
75
+
76
+ # Defining Gradio Interface using Blocks Structure
77
+ with gr.Blocks() as demo:
78
+ # Give it a Title
79
+ gr.Markdown("## Gradio - MultiModal Chatbot")
80
+ # Define the Chat Tab
81
+ with gr.Tab(label="Chat"):
82
+ with gr.Row():
83
+ with gr.Column(scale=3):
84
+ # Set a variable equal to our MultiModalChatBot class
85
+ chatBot = MultiModalChatbot(height=700, render_markdown=True, bubble_full_width=True)
86
+ with gr.Row():
87
+ with gr.Column(scale=3):
88
+ # Set a variable equal to our user message
89
+ msg = gr.Textbox(placeholder='What is the meaning of life?', show_label=False)
90
+ with gr.Column(scale=1):
91
+ # Set a variable equal to our file upload
92
+ fileInput = gr.File(label="Upload Files")
93
+ with gr.Column(scale=1):
94
+ # Define our submit button and invoke our 'get_response' function when it's clicked.
95
+ gr.Button('Submit', variant='primary').click(get_response, inputs=[msg,fileInput], outputs=chatBot)
96
+ # Same function as above, but with the 'enter' key being pressed inside the gr.Textbox() component instead of the 'submit' button.
97
+ msg.submit(get_response, inputs=[msg, fileInput], outputs=chatBot)
98
+
99
+
100
+ if __name__ == '__main__':
101
+ demo.queue().launch()
102
+ ```
103
+ """, elem_classes=["md-custom"], header_links=True)
104
+
105
+
106
+ gr.Markdown("""
107
+ ## `MultiModalChatbot`
108
+
109
+ ### Initialization
110
+ """, elem_classes=["md-custom"], header_links=True)
111
+
112
+ gr.ParamViewer(value=_docs["MultiModalChatbot"]["members"]["__init__"], linkify=['MultimodalMessage', 'FileMessage'])
113
+
114
+
115
+ gr.Markdown("### Events")
116
+ gr.ParamViewer(value=_docs["MultiModalChatbot"]["events"], linkify=['Event'])
117
+
118
+
119
+
120
+
121
+ gr.Markdown("""
122
+
123
+ ### User function
124
+
125
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
126
+
127
+ - When used as an Input, the component only impacts the input signature of the user function.
128
+ - When used as an output, the component only impacts the return signature of the user function.
129
+
130
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
131
+
132
+ - **As input:** Is passed, the preprocessed input data sent to the user's function in the backend.
133
+ - **As output:** Should return, expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.
134
+
135
+ ```python
136
+ def predict(
137
+ value: list[MultimodalMessage] | None
138
+ ) -> list[
139
+ list[str | tuple[str] | tuple[str, str] | None]
140
+ | tuple
141
+ ]
142
+ | None:
143
+ return value
144
+ ```
145
+ """, elem_classes=["md-custom", "MultiModalChatbot-user-fn"], header_links=True)
146
+
147
+
148
+
149
+
150
+ code_MultimodalMessage = gr.Markdown("""
151
+ ## `MultimodalMessage`
152
+ ```python
153
+ class MultimodalMessage(GradioModel):
154
+ text: Optional[str] = None
155
+ files: Optional[List[FileMessage]] = None
156
+ ```""", elem_classes=["md-custom", "MultimodalMessage"], header_links=True)
157
+
158
+ code_FileMessage = gr.Markdown("""
159
+ ## `FileMessage`
160
+ ```python
161
+ class FileMessage(GradioModel):
162
+ file: FileData
163
+ alt_text: Optional[str] = None
164
+ ```""", elem_classes=["md-custom", "FileMessage"], header_links=True)
165
+
166
+ demo.load(None, js=r"""function() {
167
+ const refs = {
168
+ MultimodalMessage: ['FileMessage'],
169
+ FileMessage: [], };
170
+ const user_fn_refs = {
171
+ MultiModalChatbot: ['MultimodalMessage'], };
172
+ requestAnimationFrame(() => {
173
+
174
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
175
+ if (refs.length > 0) {
176
+ const el = document.querySelector(`.${key}-user-fn`);
177
+ if (!el) return;
178
+ refs.forEach(ref => {
179
+ el.innerHTML = el.innerHTML.replace(
180
+ new RegExp("\\b"+ref+"\\b", "g"),
181
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
182
+ );
183
+ })
184
+ }
185
+ })
186
+
187
+ Object.entries(refs).forEach(([key, refs]) => {
188
+ if (refs.length > 0) {
189
+ const el = document.querySelector(`.${key}`);
190
+ if (!el) return;
191
+ refs.forEach(ref => {
192
+ el.innerHTML = el.innerHTML.replace(
193
+ new RegExp("\\b"+ref+"\\b", "g"),
194
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
195
+ );
196
+ })
197
+ }
198
+ })
199
+ })
200
+ }
201
+
202
+ """)
203
+
204
+ demo.launch()
src/.DS_Store ADDED
Binary file (6.15 kB). View file
 
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,452 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # `gradio_awsbr_mmchatbot`
3
+ <a href="https://pypi.org/project/gradio_awsbr_mmchatbot/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_awsbr_mmchatbot"></a>
4
+
5
+ This component enables multi-modal input for the Anthropic Claude v3 suite of models available from Amazon Bedrock
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install gradio_awsbr_mmchatbot
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```python
16
+ import gradio as gr
17
+ from gradio_awsbr_mmchatbot import MultiModalChatbot
18
+ from gradio.data_classes import FileData
19
+ from bedrock_utils import MultimodalInputHandler
20
+
21
+
22
+ # A function to call the multi-modal input for Anthropic Claude v3 sonnet using Bedrock boto3
23
+ async def get_response(text, file):
24
+ # If there is a file uploaded, then we will send it to Anthropic Claude v3 sonnet.
25
+ # If there is no file uploaded, then we will send the text to Anthropic Claude v3 sonnet.
26
+ try:
27
+ userMsg = {
28
+ "text": text,
29
+ "files": [{"file": FileData(path=file)}]
30
+ }
31
+ except:
32
+ userMsg = {
33
+ "text": text,
34
+ "files": []
35
+ }
36
+ # Define a variable to store the response from the Anthropic Claude v3 sonnet
37
+ llmResponse = ""
38
+ handler = MultimodalInputHandler(text, file)
39
+ # Loop through the response from Anthropic Claude v3 sonnet, and append it to our llmResponse variable.
40
+ async for x in handler.handleInput():
41
+ llmResponse += x
42
+ yield [[userMsg, {"text": llmResponse, "files": []}]]
43
+ # Yield the response from Anthropic Claude v3 sonnet. This is unecessary as we can just yield the llmResponse variable in an iterative fashion as above.
44
+ # But just in case.... let's yield the entire response object as well and overwrite the messages in the Chatbot.
45
+ response = {
46
+ "text": llmResponse,
47
+ "files": []
48
+ }
49
+ yield [[userMsg, response]]
50
+
51
+ # Defining Gradio Interface using Blocks Structure
52
+ with gr.Blocks() as demo:
53
+ # Give it a Title
54
+ gr.Markdown("## Gradio - MultiModal Chatbot")
55
+ # Define the Chat Tab
56
+ with gr.Tab(label="Chat"):
57
+ with gr.Row():
58
+ with gr.Column(scale=3):
59
+ # Set a variable equal to our MultiModalChatBot class
60
+ chatBot = MultiModalChatbot(height=700, render_markdown=True, bubble_full_width=True)
61
+ with gr.Row():
62
+ with gr.Column(scale=3):
63
+ # Set a variable equal to our user message
64
+ msg = gr.Textbox(placeholder='What is the meaning of life?', show_label=False)
65
+ with gr.Column(scale=1):
66
+ # Set a variable equal to our file upload
67
+ fileInput = gr.File(label="Upload Files")
68
+ with gr.Column(scale=1):
69
+ # Define our submit button and invoke our 'get_response' function when it's clicked.
70
+ gr.Button('Submit', variant='primary').click(get_response, inputs=[msg,fileInput], outputs=chatBot)
71
+ # Same function as above, but with the 'enter' key being pressed inside the gr.Textbox() component instead of the 'submit' button.
72
+ msg.submit(get_response, inputs=[msg, fileInput], outputs=chatBot)
73
+
74
+
75
+ if __name__ == '__main__':
76
+ demo.queue().launch()
77
+ ```
78
+
79
+ ## `MultiModalChatbot`
80
+
81
+ ### Initialization
82
+
83
+ <table>
84
+ <thead>
85
+ <tr>
86
+ <th align="left">name</th>
87
+ <th align="left" style="width: 25%;">type</th>
88
+ <th align="left">default</th>
89
+ <th align="left">description</th>
90
+ </tr>
91
+ </thead>
92
+ <tbody>
93
+ <tr>
94
+ <td align="left"><code>value</code></td>
95
+ <td align="left" style="width: 25%;">
96
+
97
+ ```python
98
+ list[
99
+ list[
100
+ str
101
+ | tuple[str]
102
+ | tuple[str | pathlib.Path, str]
103
+ | None
104
+ ]
105
+ ]
106
+ | Callable
107
+ | None
108
+ ```
109
+
110
+ </td>
111
+ <td align="left"><code>None</code></td>
112
+ <td align="left">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.</td>
113
+ </tr>
114
+
115
+ <tr>
116
+ <td align="left"><code>label</code></td>
117
+ <td align="left" style="width: 25%;">
118
+
119
+ ```python
120
+ str | None
121
+ ```
122
+
123
+ </td>
124
+ <td align="left"><code>None</code></td>
125
+ <td align="left">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.</td>
126
+ </tr>
127
+
128
+ <tr>
129
+ <td align="left"><code>every</code></td>
130
+ <td align="left" style="width: 25%;">
131
+
132
+ ```python
133
+ float | None
134
+ ```
135
+
136
+ </td>
137
+ <td align="left"><code>None</code></td>
138
+ <td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
139
+ </tr>
140
+
141
+ <tr>
142
+ <td align="left"><code>show_label</code></td>
143
+ <td align="left" style="width: 25%;">
144
+
145
+ ```python
146
+ bool | None
147
+ ```
148
+
149
+ </td>
150
+ <td align="left"><code>None</code></td>
151
+ <td align="left">if True, will display label.</td>
152
+ </tr>
153
+
154
+ <tr>
155
+ <td align="left"><code>container</code></td>
156
+ <td align="left" style="width: 25%;">
157
+
158
+ ```python
159
+ bool
160
+ ```
161
+
162
+ </td>
163
+ <td align="left"><code>True</code></td>
164
+ <td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
165
+ </tr>
166
+
167
+ <tr>
168
+ <td align="left"><code>scale</code></td>
169
+ <td align="left" style="width: 25%;">
170
+
171
+ ```python
172
+ int | None
173
+ ```
174
+
175
+ </td>
176
+ <td align="left"><code>None</code></td>
177
+ <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
178
+ </tr>
179
+
180
+ <tr>
181
+ <td align="left"><code>min_width</code></td>
182
+ <td align="left" style="width: 25%;">
183
+
184
+ ```python
185
+ int
186
+ ```
187
+
188
+ </td>
189
+ <td align="left"><code>160</code></td>
190
+ <td align="left">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.</td>
191
+ </tr>
192
+
193
+ <tr>
194
+ <td align="left"><code>visible</code></td>
195
+ <td align="left" style="width: 25%;">
196
+
197
+ ```python
198
+ bool
199
+ ```
200
+
201
+ </td>
202
+ <td align="left"><code>True</code></td>
203
+ <td align="left">If False, component will be hidden.</td>
204
+ </tr>
205
+
206
+ <tr>
207
+ <td align="left"><code>elem_id</code></td>
208
+ <td align="left" style="width: 25%;">
209
+
210
+ ```python
211
+ str | None
212
+ ```
213
+
214
+ </td>
215
+ <td align="left"><code>None</code></td>
216
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
217
+ </tr>
218
+
219
+ <tr>
220
+ <td align="left"><code>elem_classes</code></td>
221
+ <td align="left" style="width: 25%;">
222
+
223
+ ```python
224
+ list[str] | str | None
225
+ ```
226
+
227
+ </td>
228
+ <td align="left"><code>None</code></td>
229
+ <td align="left">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.</td>
230
+ </tr>
231
+
232
+ <tr>
233
+ <td align="left"><code>render</code></td>
234
+ <td align="left" style="width: 25%;">
235
+
236
+ ```python
237
+ bool
238
+ ```
239
+
240
+ </td>
241
+ <td align="left"><code>True</code></td>
242
+ <td align="left">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.</td>
243
+ </tr>
244
+
245
+ <tr>
246
+ <td align="left"><code>height</code></td>
247
+ <td align="left" style="width: 25%;">
248
+
249
+ ```python
250
+ int | str | None
251
+ ```
252
+
253
+ </td>
254
+ <td align="left"><code>None</code></td>
255
+ <td align="left">The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed.</td>
256
+ </tr>
257
+
258
+ <tr>
259
+ <td align="left"><code>latex_delimiters</code></td>
260
+ <td align="left" style="width: 25%;">
261
+
262
+ ```python
263
+ list[dict[str, str | bool]] | None
264
+ ```
265
+
266
+ </td>
267
+ <td align="left"><code>None</code></td>
268
+ <td align="left">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).</td>
269
+ </tr>
270
+
271
+ <tr>
272
+ <td align="left"><code>rtl</code></td>
273
+ <td align="left" style="width: 25%;">
274
+
275
+ ```python
276
+ bool
277
+ ```
278
+
279
+ </td>
280
+ <td align="left"><code>False</code></td>
281
+ <td align="left">If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.</td>
282
+ </tr>
283
+
284
+ <tr>
285
+ <td align="left"><code>show_share_button</code></td>
286
+ <td align="left" style="width: 25%;">
287
+
288
+ ```python
289
+ bool | None
290
+ ```
291
+
292
+ </td>
293
+ <td align="left"><code>None</code></td>
294
+ <td align="left">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.</td>
295
+ </tr>
296
+
297
+ <tr>
298
+ <td align="left"><code>show_copy_button</code></td>
299
+ <td align="left" style="width: 25%;">
300
+
301
+ ```python
302
+ bool
303
+ ```
304
+
305
+ </td>
306
+ <td align="left"><code>False</code></td>
307
+ <td align="left">If True, will show a copy button for each chatbot message.</td>
308
+ </tr>
309
+
310
+ <tr>
311
+ <td align="left"><code>avatar_images</code></td>
312
+ <td align="left" style="width: 25%;">
313
+
314
+ ```python
315
+ tuple[
316
+ str | pathlib.Path | None, str | pathlib.Path | None
317
+ ]
318
+ | None
319
+ ```
320
+
321
+ </td>
322
+ <td align="left"><code>None</code></td>
323
+ <td align="left">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.</td>
324
+ </tr>
325
+
326
+ <tr>
327
+ <td align="left"><code>sanitize_html</code></td>
328
+ <td align="left" style="width: 25%;">
329
+
330
+ ```python
331
+ bool
332
+ ```
333
+
334
+ </td>
335
+ <td align="left"><code>True</code></td>
336
+ <td align="left">If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.</td>
337
+ </tr>
338
+
339
+ <tr>
340
+ <td align="left"><code>render_markdown</code></td>
341
+ <td align="left" style="width: 25%;">
342
+
343
+ ```python
344
+ bool
345
+ ```
346
+
347
+ </td>
348
+ <td align="left"><code>True</code></td>
349
+ <td align="left">If False, will disable Markdown rendering for chatbot messages.</td>
350
+ </tr>
351
+
352
+ <tr>
353
+ <td align="left"><code>bubble_full_width</code></td>
354
+ <td align="left" style="width: 25%;">
355
+
356
+ ```python
357
+ bool
358
+ ```
359
+
360
+ </td>
361
+ <td align="left"><code>True</code></td>
362
+ <td align="left">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.</td>
363
+ </tr>
364
+
365
+ <tr>
366
+ <td align="left"><code>line_breaks</code></td>
367
+ <td align="left" style="width: 25%;">
368
+
369
+ ```python
370
+ bool
371
+ ```
372
+
373
+ </td>
374
+ <td align="left"><code>True</code></td>
375
+ <td align="left">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.</td>
376
+ </tr>
377
+
378
+ <tr>
379
+ <td align="left"><code>likeable</code></td>
380
+ <td align="left" style="width: 25%;">
381
+
382
+ ```python
383
+ bool
384
+ ```
385
+
386
+ </td>
387
+ <td align="left"><code>False</code></td>
388
+ <td align="left">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.</td>
389
+ </tr>
390
+
391
+ <tr>
392
+ <td align="left"><code>layout</code></td>
393
+ <td align="left" style="width: 25%;">
394
+
395
+ ```python
396
+ "panel" | "bubble" | None
397
+ ```
398
+
399
+ </td>
400
+ <td align="left"><code>None</code></td>
401
+ <td align="left">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".</td>
402
+ </tr>
403
+ </tbody></table>
404
+
405
+
406
+ ### Events
407
+
408
+ | name | description |
409
+ |:-----|:------------|
410
+ | `change` | Triggered when the value of the MultiModalChatbot changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
411
+ | `select` | Event listener for when the user selects or deselects the MultiModalChatbot. Uses event data gradio.SelectData to carry `value` referring to the label of the MultiModalChatbot, and `selected` to refer to state of the MultiModalChatbot. See EventData documentation on how to use this event data |
412
+ | `like` | This listener is triggered when the user likes/dislikes from within the MultiModalChatbot. This event has EventData of type gradio.LikeData that carries information, accessible through LikeData.index and LikeData.value. See EventData documentation on how to use this event data. |
413
+
414
+
415
+
416
+ ### User function
417
+
418
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
419
+
420
+ - When used as an Input, the component only impacts the input signature of the user function.
421
+ - When used as an output, the component only impacts the return signature of the user function.
422
+
423
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
424
+
425
+ - **As output:** Is passed, the preprocessed input data sent to the user's function in the backend.
426
+ - **As input:** Should return, expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.
427
+
428
+ ```python
429
+ def predict(
430
+ value: list[MultimodalMessage] | None
431
+ ) -> list[
432
+ list[str | tuple[str] | tuple[str, str] | None]
433
+ | tuple
434
+ ]
435
+ | None:
436
+ return value
437
+ ```
438
+
439
+
440
+ ## `MultimodalMessage`
441
+ ```python
442
+ class MultimodalMessage(GradioModel):
443
+ text: Optional[str] = None
444
+ files: Optional[List[FileMessage]] = None
445
+ ```
446
+
447
+ ## `FileMessage`
448
+ ```python
449
+ class FileMessage(GradioModel):
450
+ file: FileData
451
+ alt_text: Optional[str] = None
452
+ ```
src/backend/gradio_awsbr_mmchatbot/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ from .multimodalchatbot import MultiModalChatbot
3
+
4
+ __all__ = ['MultiModalChatbot']
src/backend/gradio_awsbr_mmchatbot/multimodalchatbot.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
+
18
+ class FileMessage(GradioModel):
19
+ file: FileData
20
+ alt_text: Optional[str] = None
21
+
22
+ class MultimodalMessage(GradioModel):
23
+ text: Optional[str] = None
24
+ files: Optional[List[FileMessage]] = None
25
+
26
+ class ChatbotData(GradioRootModel):
27
+ root: List[Tuple[Optional[MultimodalMessage], Optional[MultimodalMessage]]]
28
+
29
+
30
+ class MultiModalChatbot(Component):
31
+ """
32
+ Creates a chatbot that displays user-submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables.
33
+ Also supports audio/video/image files, which are displayed in the MultiModalChatbot, and other kinds of files which are displayed as links. This
34
+ component is usually used as an output component.
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 | str | 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. 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 size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
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: The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed.
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[dict | None] = [None, None]
129
+ if avatar_images is None:
130
+ pass
131
+ else:
132
+ self.avatar_images = [
133
+ self.serve_static_file(avatar_images[0]),
134
+ self.serve_static_file(avatar_images[1]),
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 MultiModalChatbot component: {chat_message}")
151
+
152
+ def preprocess(
153
+ self,
154
+ payload: ChatbotData | None,
155
+ ) -> List[MultimodalMessage] | None:
156
+ if payload is None:
157
+ return payload
158
+ return payload.root
159
+
160
+ def _postprocess_chat_messages(
161
+ self, chat_message: MultimodalMessage | dict | None
162
+ ) -> MultimodalMessage | None:
163
+ if chat_message is None:
164
+ return None
165
+ if isinstance(chat_message, dict):
166
+ chat_message = MultimodalMessage(**chat_message)
167
+ chat_message.text = inspect.cleandoc(chat_message.text or "")
168
+ for file_ in chat_message.files:
169
+ file_.file.mime_type = client_utils.get_mimetype(file_.file.path)
170
+ return chat_message
171
+
172
+ def postprocess(
173
+ self,
174
+ value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple] | None,
175
+ ) -> ChatbotData:
176
+ """
177
+ Parameters:
178
+ value: expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.
179
+ Returns:
180
+ an object of type ChatbotData
181
+ """
182
+ if value is None:
183
+ return ChatbotData(root=[])
184
+ processed_messages = []
185
+ for message_pair in value:
186
+ if not isinstance(message_pair, (tuple, list)):
187
+ raise TypeError(
188
+ f"Expected a list of lists or list of tuples. Received: {message_pair}"
189
+ )
190
+ if len(message_pair) != 2:
191
+ raise TypeError(
192
+ f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
193
+ )
194
+ processed_messages.append(
195
+ [
196
+ self._postprocess_chat_messages(message_pair[0]),
197
+ self._postprocess_chat_messages(message_pair[1]),
198
+ ]
199
+ )
200
+ return ChatbotData(root=processed_messages)
201
+
202
+ def example_payload(self) -> Any:
203
+ return [[{"text": "Hello!", "files": []}, None]]
204
+
205
+ def example_value(self) -> Any:
206
+ return [[{"text": "Hello!", "files": []}, None]]
src/backend/gradio_awsbr_mmchatbot/multimodalchatbot.pyi ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
+
18
+ class FileMessage(GradioModel):
19
+ file: FileData
20
+ alt_text: Optional[str] = None
21
+
22
+
23
+ class ChatbotData(GradioRootModel):
24
+ root: List[Tuple[Union[str, FileMessage, None], Union[str, FileMessage, None]]]
25
+
26
+
27
+ class MultiModalChatbot(Component):
28
+ """
29
+ Creates a chatbot that displays user-submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables.
30
+ Also supports audio/video/image files, which are displayed in the MultiModalChatbot, and other kinds of files which are displayed as links. This
31
+ component is usually used as an output component.
32
+
33
+ Demos: chatbot_simple, chatbot_multimodal
34
+ Guides: creating-a-chatbot
35
+ """
36
+
37
+ EVENTS = [Events.change, Events.select, Events.like]
38
+ data_model = ChatbotData
39
+
40
+ def __init__(
41
+ self,
42
+ value: list[list[str | tuple[str] | tuple[str | Path, str] | None]]
43
+ | Callable
44
+ | None = None,
45
+ *,
46
+ label: str | None = None,
47
+ every: float | None = None,
48
+ show_label: bool | None = None,
49
+ container: bool = True,
50
+ scale: int | None = None,
51
+ min_width: int = 160,
52
+ visible: bool = True,
53
+ elem_id: str | None = None,
54
+ elem_classes: list[str] | str | None = None,
55
+ render: bool = True,
56
+ height: int | str | None = None,
57
+ latex_delimiters: list[dict[str, str | bool]] | None = None,
58
+ rtl: bool = False,
59
+ show_share_button: bool | None = None,
60
+ show_copy_button: bool = False,
61
+ avatar_images: tuple[str | Path | None, str | Path | None] | None = None,
62
+ sanitize_html: bool = True,
63
+ render_markdown: bool = True,
64
+ bubble_full_width: bool = True,
65
+ line_breaks: bool = True,
66
+ likeable: bool = False,
67
+ layout: Literal["panel", "bubble"] | None = None,
68
+ ):
69
+ """
70
+ Parameters:
71
+ 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.
72
+ 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.
73
+ every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
74
+ show_label: if True, will display label.
75
+ container: If True, will place the component in a container - providing some extra padding around the border.
76
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
77
+ 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.
78
+ visible: If False, component will be hidden.
79
+ 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.
80
+ 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.
81
+ 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.
82
+ height: The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed.
83
+ 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).
84
+ rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
85
+ 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.
86
+ show_copy_button: If True, will show a copy button for each chatbot message.
87
+ 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.
88
+ sanitize_html: If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.
89
+ render_markdown: If False, will disable Markdown rendering for chatbot messages.
90
+ 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.
91
+ 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.
92
+ 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.
93
+ 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".
94
+ """
95
+ self.likeable = likeable
96
+ self.height = height
97
+ self.rtl = rtl
98
+ if latex_delimiters is None:
99
+ latex_delimiters = [{"left": "$$", "right": "$$", "display": True}]
100
+ self.latex_delimiters = latex_delimiters
101
+ self.show_share_button = (
102
+ (utils.get_space() is not None)
103
+ if show_share_button is None
104
+ else show_share_button
105
+ )
106
+ self.render_markdown = render_markdown
107
+ self.show_copy_button = show_copy_button
108
+ self.sanitize_html = sanitize_html
109
+ self.bubble_full_width = bubble_full_width
110
+ self.line_breaks = line_breaks
111
+ self.layout = layout
112
+ super().__init__(
113
+ label=label,
114
+ every=every,
115
+ show_label=show_label,
116
+ container=container,
117
+ scale=scale,
118
+ min_width=min_width,
119
+ visible=visible,
120
+ elem_id=elem_id,
121
+ elem_classes=elem_classes,
122
+ render=render,
123
+ value=value,
124
+ )
125
+ self.avatar_images: list[dict | None] = [None, None]
126
+ if avatar_images is None:
127
+ pass
128
+ else:
129
+ self.avatar_images = [
130
+ self.serve_static_file(avatar_images[0]),
131
+ self.serve_static_file(avatar_images[1]),
132
+ ]
133
+
134
+ def _preprocess_chat_messages(
135
+ self, chat_message: str | FileMessage | None
136
+ ) -> str | tuple[str | None] | tuple[str | None, str] | None:
137
+ if chat_message is None:
138
+ return None
139
+ elif isinstance(chat_message, FileMessage):
140
+ if chat_message.alt_text is not None:
141
+ return (chat_message.file.path, chat_message.alt_text)
142
+ else:
143
+ return (chat_message.file.path,)
144
+ elif isinstance(chat_message, str):
145
+ return chat_message
146
+ else:
147
+ raise ValueError(f"Invalid message for MultiModalChatbot component: {chat_message}")
148
+
149
+ def preprocess(
150
+ self,
151
+ payload: ChatbotData | None,
152
+ ) -> List[MultimodalMessage] | None:
153
+ if payload is None:
154
+ return payload
155
+ return payload.root
156
+
157
+ def _postprocess_chat_messages(
158
+ self, chat_message: MultimodalMessage | dict | None
159
+ ) -> MultimodalMessage | None:
160
+ if chat_message is None:
161
+ return None
162
+ if isinstance(chat_message, dict):
163
+ chat_message = MultimodalMessage(**chat_message)
164
+ chat_message.text = inspect.cleandoc(chat_message.text or "")
165
+ for file_ in chat_message.files:
166
+ file_.file.mime_type = client_utils.get_mimetype(file_.file.path)
167
+ return chat_message
168
+
169
+ def postprocess(
170
+ self,
171
+ value: list[list[str | tuple[str] | tuple[str, str] | None] | tuple] | None,
172
+ ) -> ChatbotData:
173
+ """
174
+ Parameters:
175
+ value: expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.
176
+ Returns:
177
+ an object of type ChatbotData
178
+ """
179
+ if value is None:
180
+ return ChatbotData(root=[])
181
+ processed_messages = []
182
+ for message_pair in value:
183
+ if not isinstance(message_pair, (tuple, list)):
184
+ raise TypeError(
185
+ f"Expected a list of lists or list of tuples. Received: {message_pair}"
186
+ )
187
+ if len(message_pair) != 2:
188
+ raise TypeError(
189
+ f"Expected a list of lists of length 2 or list of tuples of length 2. Received: {message_pair}"
190
+ )
191
+ processed_messages.append(
192
+ [
193
+ self._postprocess_chat_messages(message_pair[0]),
194
+ self._postprocess_chat_messages(message_pair[1]),
195
+ ]
196
+ )
197
+ return ChatbotData(root=processed_messages)
198
+
199
+ def example_payload(self) -> Any:
200
+ return [[{"text": "Hello!", "files": []}, None]]
201
+
202
+ def example_value(self) -> Any:
203
+ return [[{"text": "Hello!", "files": []}, None]]
204
+
205
+
206
+ def change(self,
207
+ fn: Callable | None,
208
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
209
+ outputs: Component | Sequence[Component] | None = None,
210
+ api_name: str | None | Literal[False] = None,
211
+ scroll_to_output: bool = False,
212
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
213
+ queue: bool | None = None,
214
+ batch: bool = False,
215
+ max_batch_size: int = 4,
216
+ preprocess: bool = True,
217
+ postprocess: bool = True,
218
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
219
+ every: float | None = None,
220
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
221
+ js: str | None = None,
222
+ concurrency_limit: int | None | Literal["default"] = "default",
223
+ concurrency_id: str | None = None,
224
+ show_api: bool = True) -> Dependency:
225
+ """
226
+ Parameters:
227
+ 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.
228
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
229
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
230
+ 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.
231
+ scroll_to_output: If True, will scroll to output component on completion
232
+ show_progress: If True, will show progress animation while pending
233
+ 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.
234
+ 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.
235
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
236
+ 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).
237
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
238
+ 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.
239
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds.
240
+ 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()` and `.key_up()` events) would allow a second submission after the pending event is complete.
241
+ 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.
242
+ concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
243
+ concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
244
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
245
+ """
246
+ ...
247
+
248
+ def select(self,
249
+ fn: Callable | None,
250
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
251
+ outputs: Component | Sequence[Component] | None = None,
252
+ api_name: str | None | Literal[False] = None,
253
+ scroll_to_output: bool = False,
254
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
255
+ queue: bool | None = None,
256
+ batch: bool = False,
257
+ max_batch_size: int = 4,
258
+ preprocess: bool = True,
259
+ postprocess: bool = True,
260
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
261
+ every: float | None = None,
262
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
263
+ js: str | None = None,
264
+ concurrency_limit: int | None | Literal["default"] = "default",
265
+ concurrency_id: str | None = None,
266
+ show_api: bool = True) -> Dependency:
267
+ """
268
+ Parameters:
269
+ 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.
270
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
271
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
272
+ 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.
273
+ scroll_to_output: If True, will scroll to output component on completion
274
+ show_progress: If True, will show progress animation while pending
275
+ 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.
276
+ 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.
277
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
278
+ 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).
279
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
280
+ 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.
281
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds.
282
+ 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()` and `.key_up()` events) would allow a second submission after the pending event is complete.
283
+ 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.
284
+ concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
285
+ concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
286
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
287
+ """
288
+ ...
289
+
290
+ def like(self,
291
+ fn: Callable | None,
292
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
293
+ outputs: Component | Sequence[Component] | None = None,
294
+ api_name: str | None | Literal[False] = None,
295
+ scroll_to_output: bool = False,
296
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
297
+ queue: bool | None = None,
298
+ batch: bool = False,
299
+ max_batch_size: int = 4,
300
+ preprocess: bool = True,
301
+ postprocess: bool = True,
302
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
303
+ every: float | None = None,
304
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
305
+ js: str | None = None,
306
+ concurrency_limit: int | None | Literal["default"] = "default",
307
+ concurrency_id: str | None = None,
308
+ show_api: bool = True) -> Dependency:
309
+ """
310
+ Parameters:
311
+ 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.
312
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
313
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
314
+ 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.
315
+ scroll_to_output: If True, will scroll to output component on completion
316
+ show_progress: If True, will show progress animation while pending
317
+ 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.
318
+ 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.
319
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
320
+ 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).
321
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
322
+ 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.
323
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds.
324
+ 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()` and `.key_up()` events) would allow a second submission after the pending event is complete.
325
+ 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.
326
+ concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
327
+ concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
328
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
329
+ """
330
+ ...
src/backend/gradio_awsbr_mmchatbot/templates/component/assets/worker-43d19264.js ADDED
@@ -0,0 +1 @@
 
 
1
+ (function(){"use strict";const R="https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd/ffmpeg-core.js";var E;(function(t){t.LOAD="LOAD",t.EXEC="EXEC",t.WRITE_FILE="WRITE_FILE",t.READ_FILE="READ_FILE",t.DELETE_FILE="DELETE_FILE",t.RENAME="RENAME",t.CREATE_DIR="CREATE_DIR",t.LIST_DIR="LIST_DIR",t.DELETE_DIR="DELETE_DIR",t.ERROR="ERROR",t.DOWNLOAD="DOWNLOAD",t.PROGRESS="PROGRESS",t.LOG="LOG",t.MOUNT="MOUNT",t.UNMOUNT="UNMOUNT"})(E||(E={}));const a=new Error("unknown message type"),f=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),u=new Error("failed to import ffmpeg-core.js");let r;const O=async({coreURL:t,wasmURL:n,workerURL:e})=>{const o=!r;try{t||(t=R),importScripts(t)}catch{if(t||(t=R.replace("/umd/","/esm/")),self.createFFmpegCore=(await import(t)).default,!self.createFFmpegCore)throw u}const s=t,c=n||t.replace(/.js$/g,".wasm"),b=e||t.replace(/.js$/g,".worker.js");return r=await self.createFFmpegCore({mainScriptUrlOrBlob:`${s}#${btoa(JSON.stringify({wasmURL:c,workerURL:b}))}`}),r.setLogger(i=>self.postMessage({type:E.LOG,data:i})),r.setProgress(i=>self.postMessage({type:E.PROGRESS,data:i})),o},l=({args:t,timeout:n=-1})=>{r.setTimeout(n),r.exec(...t);const e=r.ret;return r.reset(),e},m=({path:t,data:n})=>(r.FS.writeFile(t,n),!0),D=({path:t,encoding:n})=>r.FS.readFile(t,{encoding:n}),S=({path:t})=>(r.FS.unlink(t),!0),I=({oldPath:t,newPath:n})=>(r.FS.rename(t,n),!0),L=({path:t})=>(r.FS.mkdir(t),!0),N=({path:t})=>{const n=r.FS.readdir(t),e=[];for(const o of n){const s=r.FS.stat(`${t}/${o}`),c=r.FS.isDir(s.mode);e.push({name:o,isDir:c})}return e},A=({path:t})=>(r.FS.rmdir(t),!0),w=({fsType:t,options:n,mountPoint:e})=>{const o=t,s=r.FS.filesystems[o];return s?(r.FS.mount(s,n,e),!0):!1},k=({mountPoint:t})=>(r.FS.unmount(t),!0);self.onmessage=async({data:{id:t,type:n,data:e}})=>{const o=[];let s;try{if(n!==E.LOAD&&!r)throw f;switch(n){case E.LOAD:s=await O(e);break;case E.EXEC:s=l(e);break;case E.WRITE_FILE:s=m(e);break;case E.READ_FILE:s=D(e);break;case E.DELETE_FILE:s=S(e);break;case E.RENAME:s=I(e);break;case E.CREATE_DIR:s=L(e);break;case E.LIST_DIR:s=N(e);break;case E.DELETE_DIR:s=A(e);break;case E.MOUNT:s=w(e);break;case E.UNMOUNT:s=k(e);break;default:throw a}}catch(c){self.postMessage({id:t,type:E.ERROR,data:c.toString()});return}s instanceof Uint8Array&&o.push(s.buffer),self.postMessage({id:t,type:n,data:s},o)}})();
src/backend/gradio_awsbr_mmchatbot/templates/component/index.js ADDED
The diff for this file is too large to render. See raw diff
 
src/backend/gradio_awsbr_mmchatbot/templates/component/style.css ADDED
The diff for this file is too large to render. See raw diff
 
src/demo/__init__.py ADDED
File without changes
src/demo/app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_awsbr_mmchatbot import MultiModalChatbot
3
+ from gradio.data_classes import FileData
4
+ from bedrock_utils import MultimodalInputHandler
5
+
6
+
7
+ # A function to call the multi-modal input for Anthropic Claude v3 sonnet using Bedrock boto3
8
+ async def get_response(text, file):
9
+ # If there is a file uploaded, then we will send it to Anthropic Claude v3 sonnet.
10
+ # If there is no file uploaded, then we will send the text to Anthropic Claude v3 sonnet.
11
+ try:
12
+ userMsg = {
13
+ "text": text,
14
+ "files": [{"file": FileData(path=file)}]
15
+ }
16
+ except:
17
+ userMsg = {
18
+ "text": text,
19
+ "files": []
20
+ }
21
+ # Define a variable to store the response from the Anthropic Claude v3 sonnet
22
+ llmResponse = ""
23
+ handler = MultimodalInputHandler(text, file)
24
+ # Loop through the response from Anthropic Claude v3 sonnet, and append it to our llmResponse variable.
25
+ async for x in handler.handleInput():
26
+ llmResponse += x
27
+ yield [[userMsg, {"text": llmResponse, "files": []}]]
28
+ # Yield the response from Anthropic Claude v3 sonnet. This is unecessary as we can just yield the llmResponse variable in an iterative fashion as above.
29
+ # But just in case.... let's yield the entire response object as well and overwrite the messages in the Chatbot.
30
+ response = {
31
+ "text": llmResponse,
32
+ "files": []
33
+ }
34
+ yield [[userMsg, response]]
35
+
36
+ # Defining Gradio Interface using Blocks Structure
37
+ with gr.Blocks() as demo:
38
+ # Give it a Title
39
+ gr.Markdown("## Gradio - MultiModal Chatbot")
40
+ # Define the Chat Tab
41
+ with gr.Tab(label="Chat"):
42
+ with gr.Row():
43
+ with gr.Column(scale=3):
44
+ # Set a variable equal to our MultiModalChatBot class
45
+ chatBot = MultiModalChatbot(height=700, render_markdown=True, bubble_full_width=True)
46
+ with gr.Row():
47
+ with gr.Column(scale=3):
48
+ # Set a variable equal to our user message
49
+ msg = gr.Textbox(placeholder='What is the meaning of life?', show_label=False)
50
+ with gr.Column(scale=1):
51
+ # Set a variable equal to our file upload
52
+ fileInput = gr.File(label="Upload Files")
53
+ with gr.Column(scale=1):
54
+ # Define our submit button and invoke our 'get_response' function when it's clicked.
55
+ gr.Button('Submit', variant='primary').click(get_response, inputs=[msg,fileInput], outputs=chatBot)
56
+ # Same function as above, but with the 'enter' key being pressed inside the gr.Textbox() component instead of the 'submit' button.
57
+ msg.submit(get_response, inputs=[msg, fileInput], outputs=chatBot)
58
+
59
+
60
+ if __name__ == '__main__':
61
+ demo.queue().launch()
src/demo/bedrock_utils.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import base64
3
+ import os
4
+ from anthropic import AnthropicBedrock
5
+ from PIL import Image
6
+
7
+ class MultimodalInputHandler:
8
+ def __init__(self, text, image=None):
9
+ self.text = text
10
+ self.image = image
11
+
12
+ self.client = AnthropicBedrock(
13
+ aws_region='us-west-2'
14
+ )
15
+
16
+ async def handleInput(self):
17
+ if self.image:
18
+
19
+ # Determine the format of the image
20
+ if self.image.endswith(".jpg"):
21
+ formatType = "image/jpeg"
22
+ elif self.image.endswith(".png"):
23
+ formatType = "image/png"
24
+ elif self.image.endswith(".gif"):
25
+ formatType = "image/gif"
26
+ elif self.image.endswith(".webp"):
27
+ formatType = "image/webp"
28
+
29
+ # Encode the image as base64
30
+ b64EncodedImage = base64.b64encode(open(self.image, "rb").read())
31
+
32
+ # Send the image and text to the Anthropic API
33
+ with self.client.messages.stream(
34
+ model="anthropic.claude-3-sonnet-20240229-v1:0",
35
+ max_tokens=5000,
36
+ messages=[{
37
+ 'role': 'user',
38
+ 'content': [
39
+ {
40
+ "type": "image",
41
+ "source": {
42
+ "type": "base64",
43
+ "media_type": formatType,
44
+ "data": b64EncodedImage.decode("utf-8")
45
+ }
46
+ },
47
+ {
48
+ "type": "text",
49
+ "text": self.text
50
+ }
51
+ ]
52
+ }]
53
+ ) as stream:
54
+ for text in stream.text_stream:
55
+ yield text
56
+ else:
57
+ # Send the text to the Anthropic API
58
+ with self.client.messages.stream(
59
+ model="anthropic.claude-3-sonnet-20240229-v1:0",
60
+ max_tokens=5000,
61
+ messages=[{
62
+ 'role': 'user',
63
+ 'content': self.text
64
+ }]
65
+ ) as stream:
66
+ for text in stream.text_stream:
67
+ yield text
68
+
69
+ # MultimodalInputHandler = MultimodalInputHandler("What is this image?", "path/to/my/file")
70
+ # print(MultimodalInputHandler.handleInput())
src/demo/css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
src/demo/space.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'MultiModalChatbot': {'description': 'Creates a chatbot that displays user-submitted messages and responses. Supports a subset of Markdown including bold, italics, code, tables.\nAlso supports audio/video/image files, which are displayed in the MultiModalChatbot, and other kinds of files which are displayed as links. This\ncomponent is usually used as an output component.\n', 'members': {'__init__': {'value': {'type': 'list[\n list[\n str\n | tuple[str]\n | tuple[str | pathlib.Path, str]\n | None\n ]\n ]\n | Callable\n | None', 'default': 'None', 'description': '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.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': '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.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': '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.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': '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.'}, 'render': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'height': {'type': 'int | str | None', 'default': 'None', 'description': 'The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed.'}, 'latex_delimiters': {'type': 'list[dict[str, str | bool]] | None', 'default': 'None', 'description': '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).'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': '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.'}, 'show_copy_button': {'type': 'bool', 'default': 'False', 'description': 'If True, will show a copy button for each chatbot message.'}, 'avatar_images': {'type': 'tuple[\n str | pathlib.Path | None, str | pathlib.Path | None\n ]\n | None', 'default': 'None', 'description': '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.'}, 'sanitize_html': {'type': 'bool', 'default': 'True', 'description': 'If False, will disable HTML sanitization for chatbot messages. This is not recommended, as it can lead to security vulnerabilities.'}, 'render_markdown': {'type': 'bool', 'default': 'True', 'description': 'If False, will disable Markdown rendering for chatbot messages.'}, 'bubble_full_width': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'line_breaks': {'type': 'bool', 'default': 'True', 'description': '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.'}, 'likeable': {'type': 'bool', 'default': 'False', 'description': '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.'}, 'layout': {'type': '"panel" | "bubble" | None', 'default': 'None', 'description': '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".'}}, 'postprocess': {'value': {'type': 'list[\n list[str | tuple[str] | tuple[str, str] | None]\n | tuple\n ]\n | None', 'description': 'expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.'}}, 'preprocess': {'return': {'type': 'list[MultimodalMessage] | None', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the MultiModalChatbot changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the MultiModalChatbot. Uses event data gradio.SelectData to carry `value` referring to the label of the MultiModalChatbot, and `selected` to refer to state of the MultiModalChatbot. See EventData documentation on how to use this event data'}, 'like': {'type': None, 'default': None, 'description': 'This listener is triggered when the user likes/dislikes from within the MultiModalChatbot. This event has EventData of type gradio.LikeData that carries information, accessible through LikeData.index and LikeData.value. See EventData documentation on how to use this event data.'}}}, '__meta__': {'additional_interfaces': {'MultimodalMessage': {'source': 'class MultimodalMessage(GradioModel):\n text: Optional[str] = None\n files: Optional[List[FileMessage]] = None', 'refs': ['FileMessage']}, 'FileMessage': {'source': 'class FileMessage(GradioModel):\n file: FileData\n alt_text: Optional[str] = None'}}, 'user_fn_refs': {'MultiModalChatbot': ['MultimodalMessage']}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_awsbr_mmchatbot`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_awsbr_mmchatbot/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_awsbr_mmchatbot"></a>
25
+ </div>
26
+
27
+ This component enables multi-modal input for the Anthropic Claude v3 suite of models available from Amazon Bedrock
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_awsbr_mmchatbot
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ import gradio as gr
42
+ from gradio_awsbr_mmchatbot import MultiModalChatbot
43
+ from gradio.data_classes import FileData
44
+ from bedrock_utils import MultimodalInputHandler
45
+
46
+
47
+ # A function to call the multi-modal input for Anthropic Claude v3 sonnet using Bedrock boto3
48
+ async def get_response(text, file):
49
+ # If there is a file uploaded, then we will send it to Anthropic Claude v3 sonnet.
50
+ # If there is no file uploaded, then we will send the text to Anthropic Claude v3 sonnet.
51
+ try:
52
+ userMsg = {
53
+ "text": text,
54
+ "files": [{"file": FileData(path=file)}]
55
+ }
56
+ except:
57
+ userMsg = {
58
+ "text": text,
59
+ "files": []
60
+ }
61
+ # Define a variable to store the response from the Anthropic Claude v3 sonnet
62
+ llmResponse = ""
63
+ handler = MultimodalInputHandler(text, file)
64
+ # Loop through the response from Anthropic Claude v3 sonnet, and append it to our llmResponse variable.
65
+ async for x in handler.handleInput():
66
+ llmResponse += x
67
+ yield [[userMsg, {"text": llmResponse, "files": []}]]
68
+ # Yield the response from Anthropic Claude v3 sonnet. This is unecessary as we can just yield the llmResponse variable in an iterative fashion as above.
69
+ # But just in case.... let's yield the entire response object as well and overwrite the messages in the Chatbot.
70
+ response = {
71
+ "text": llmResponse,
72
+ "files": []
73
+ }
74
+ yield [[userMsg, response]]
75
+
76
+ # Defining Gradio Interface using Blocks Structure
77
+ with gr.Blocks() as demo:
78
+ # Give it a Title
79
+ gr.Markdown("## Gradio - MultiModal Chatbot")
80
+ # Define the Chat Tab
81
+ with gr.Tab(label="Chat"):
82
+ with gr.Row():
83
+ with gr.Column(scale=3):
84
+ # Set a variable equal to our MultiModalChatBot class
85
+ chatBot = MultiModalChatbot(height=700, render_markdown=True, bubble_full_width=True)
86
+ with gr.Row():
87
+ with gr.Column(scale=3):
88
+ # Set a variable equal to our user message
89
+ msg = gr.Textbox(placeholder='What is the meaning of life?', show_label=False)
90
+ with gr.Column(scale=1):
91
+ # Set a variable equal to our file upload
92
+ fileInput = gr.File(label="Upload Files")
93
+ with gr.Column(scale=1):
94
+ # Define our submit button and invoke our 'get_response' function when it's clicked.
95
+ gr.Button('Submit', variant='primary').click(get_response, inputs=[msg,fileInput], outputs=chatBot)
96
+ # Same function as above, but with the 'enter' key being pressed inside the gr.Textbox() component instead of the 'submit' button.
97
+ msg.submit(get_response, inputs=[msg, fileInput], outputs=chatBot)
98
+
99
+
100
+ if __name__ == '__main__':
101
+ demo.queue().launch()
102
+ ```
103
+ """, elem_classes=["md-custom"], header_links=True)
104
+
105
+
106
+ gr.Markdown("""
107
+ ## `MultiModalChatbot`
108
+
109
+ ### Initialization
110
+ """, elem_classes=["md-custom"], header_links=True)
111
+
112
+ gr.ParamViewer(value=_docs["MultiModalChatbot"]["members"]["__init__"], linkify=['MultimodalMessage', 'FileMessage'])
113
+
114
+
115
+ gr.Markdown("### Events")
116
+ gr.ParamViewer(value=_docs["MultiModalChatbot"]["events"], linkify=['Event'])
117
+
118
+
119
+
120
+
121
+ gr.Markdown("""
122
+
123
+ ### User function
124
+
125
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
126
+
127
+ - When used as an Input, the component only impacts the input signature of the user function.
128
+ - When used as an output, the component only impacts the return signature of the user function.
129
+
130
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
131
+
132
+ - **As input:** Is passed, the preprocessed input data sent to the user's function in the backend.
133
+ - **As output:** Should return, expects a `list[list[str | None | tuple]]`, i.e. a list of lists. The inner list should have 2 elements: the user message and the response message. The individual messages can be (1) strings in valid Markdown, (2) tuples if sending files: (a filepath or URL to a file, [optional string alt text]) -- if the file is image/video/audio, it is displayed in the MultiModalChatbot, or (3) None, in which case the message is not displayed.
134
+
135
+ ```python
136
+ def predict(
137
+ value: list[MultimodalMessage] | None
138
+ ) -> list[
139
+ list[str | tuple[str] | tuple[str, str] | None]
140
+ | tuple
141
+ ]
142
+ | None:
143
+ return value
144
+ ```
145
+ """, elem_classes=["md-custom", "MultiModalChatbot-user-fn"], header_links=True)
146
+
147
+
148
+
149
+
150
+ code_MultimodalMessage = gr.Markdown("""
151
+ ## `MultimodalMessage`
152
+ ```python
153
+ class MultimodalMessage(GradioModel):
154
+ text: Optional[str] = None
155
+ files: Optional[List[FileMessage]] = None
156
+ ```""", elem_classes=["md-custom", "MultimodalMessage"], header_links=True)
157
+
158
+ code_FileMessage = gr.Markdown("""
159
+ ## `FileMessage`
160
+ ```python
161
+ class FileMessage(GradioModel):
162
+ file: FileData
163
+ alt_text: Optional[str] = None
164
+ ```""", elem_classes=["md-custom", "FileMessage"], header_links=True)
165
+
166
+ demo.load(None, js=r"""function() {
167
+ const refs = {
168
+ MultimodalMessage: ['FileMessage'],
169
+ FileMessage: [], };
170
+ const user_fn_refs = {
171
+ MultiModalChatbot: ['MultimodalMessage'], };
172
+ requestAnimationFrame(() => {
173
+
174
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
175
+ if (refs.length > 0) {
176
+ const el = document.querySelector(`.${key}-user-fn`);
177
+ if (!el) return;
178
+ refs.forEach(ref => {
179
+ el.innerHTML = el.innerHTML.replace(
180
+ new RegExp("\\b"+ref+"\\b", "g"),
181
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
182
+ );
183
+ })
184
+ }
185
+ })
186
+
187
+ Object.entries(refs).forEach(([key, refs]) => {
188
+ if (refs.length > 0) {
189
+ const el = document.querySelector(`.${key}`);
190
+ if (!el) return;
191
+ refs.forEach(ref => {
192
+ el.innerHTML = el.innerHTML.replace(
193
+ new RegExp("\\b"+ref+"\\b", "g"),
194
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
195
+ );
196
+ })
197
+ }
198
+ })
199
+ })
200
+ }
201
+
202
+ """)
203
+
204
+ demo.launch()
src/frontend/Index.svelte ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import type { FileMessage, MultimodalMessage } from "./shared/utils";
8
+
9
+ import ChatBot from "./shared/ChatBot.svelte";
10
+ import { Block, BlockLabel } from "@gradio/atoms";
11
+ import type { LoadingStatus } from "@gradio/statustracker";
12
+ import { Chat } from "@gradio/icons";
13
+ import type { FileData } from "@gradio/client";
14
+ import { StatusTracker } from "@gradio/statustracker";
15
+
16
+ export let elem_id = "";
17
+ export let elem_classes: string[] = [];
18
+ export let visible = true;
19
+ export let value: [
20
+ MultimodalMessage | null,
21
+ MultimodalMessage | null
22
+ ][] = [];
23
+ export let scale: number | null = null;
24
+ export let min_width: number | undefined = undefined;
25
+ export let label: string;
26
+ export let show_label = true;
27
+ export let root: string;
28
+ export let _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: [FileData | null, FileData | null] = [null, null];
51
+
52
+ let _value: [
53
+ MultimodalMessage | null,
54
+ MultimodalMessage | 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: message?.file as FileData,
68
+ alt_text: message?.alt_text
69
+ };
70
+ }
71
+
72
+ function process_message(msg: MultimodalMessage | null): MultimodalMessage | null {
73
+ if (msg === null) {
74
+ return msg;
75
+ }
76
+ msg.text = redirect_src_url(msg.text);
77
+ msg.files = msg.files.map(normalize_messages);
78
+ return msg;
79
+ }
80
+
81
+ $: _value = value
82
+ ? value.map(([user_msg, bot_msg]) => [
83
+ process_message(user_msg),
84
+ process_message(bot_msg)
85
+ ])
86
+ : [];
87
+ export let loading_status: LoadingStatus | undefined = undefined;
88
+ export let height = 400;
89
+ </script>
90
+
91
+ <Block
92
+ {elem_id}
93
+ {elem_classes}
94
+ {visible}
95
+ padding={false}
96
+ {scale}
97
+ {min_width}
98
+ {height}
99
+ allow_overflow={false}
100
+ >
101
+ {#if loading_status}
102
+ <StatusTracker
103
+ autoscroll={gradio.autoscroll}
104
+ i18n={gradio.i18n}
105
+ {...loading_status}
106
+ show_progress={loading_status.show_progress === "hidden"
107
+ ? "hidden"
108
+ : "minimal"}
109
+ />
110
+ {/if}
111
+ <div class="wrapper">
112
+ {#if show_label}
113
+ <BlockLabel
114
+ {show_label}
115
+ Icon={Chat}
116
+ float={false}
117
+ label={label || "Chatbot"}
118
+ />
119
+ {/if}
120
+ <ChatBot
121
+ i18n={gradio.i18n}
122
+ selectable={_selectable}
123
+ {likeable}
124
+ {show_share_button}
125
+ value={_value}
126
+ {latex_delimiters}
127
+ {render_markdown}
128
+ pending_message={loading_status?.status === "pending"}
129
+ {rtl}
130
+ {show_copy_button}
131
+ on:change={() => gradio.dispatch("change", value)}
132
+ on:select={(e) => gradio.dispatch("select", e.detail)}
133
+ on:like={(e) => gradio.dispatch("like", e.detail)}
134
+ on:share={(e) => gradio.dispatch("share", e.detail)}
135
+ on:error={(e) => gradio.dispatch("error", e.detail)}
136
+ {avatar_images}
137
+ {sanitize_html}
138
+ {bubble_full_width}
139
+ {line_breaks}
140
+ {layout}
141
+ />
142
+ </div>
143
+ </Block>
144
+
145
+ <style>
146
+ .wrapper {
147
+ display: flex;
148
+ position: relative;
149
+ flex-direction: column;
150
+ align-items: start;
151
+ width: 100%;
152
+ height: 100%;
153
+ }
154
+ </style>
src/frontend/package-lock.json ADDED
@@ -0,0 +1,1560 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_multimodalchatbot",
3
+ "version": "0.7.6",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "gradio_multimodalchatbot",
9
+ "version": "0.7.6",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "@gradio/atoms": "0.5.3",
13
+ "@gradio/audio": "0.9.6",
14
+ "@gradio/client": "0.13.0",
15
+ "@gradio/icons": "0.3.3",
16
+ "@gradio/image": "0.9.6",
17
+ "@gradio/markdown": "0.6.5",
18
+ "@gradio/statustracker": "0.4.8",
19
+ "@gradio/theme": "0.2.0",
20
+ "@gradio/upload": "0.7.7",
21
+ "@gradio/utils": "0.3.0",
22
+ "@gradio/video": "0.6.6",
23
+ "@types/dompurify": "^3.0.2",
24
+ "@types/katex": "^0.16.0",
25
+ "@types/prismjs": "1.26.3",
26
+ "dequal": "^2.0.2"
27
+ }
28
+ },
29
+ "node_modules/@ampproject/remapping": {
30
+ "version": "2.3.0",
31
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
32
+ "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
33
+ "peer": true,
34
+ "dependencies": {
35
+ "@jridgewell/gen-mapping": "^0.3.5",
36
+ "@jridgewell/trace-mapping": "^0.3.24"
37
+ },
38
+ "engines": {
39
+ "node": ">=6.0.0"
40
+ }
41
+ },
42
+ "node_modules/@babel/runtime": {
43
+ "version": "7.24.4",
44
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz",
45
+ "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==",
46
+ "dependencies": {
47
+ "regenerator-runtime": "^0.14.0"
48
+ },
49
+ "engines": {
50
+ "node": ">=6.9.0"
51
+ }
52
+ },
53
+ "node_modules/@esbuild/aix-ppc64": {
54
+ "version": "0.19.12",
55
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
56
+ "integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
57
+ "cpu": [
58
+ "ppc64"
59
+ ],
60
+ "optional": true,
61
+ "os": [
62
+ "aix"
63
+ ],
64
+ "engines": {
65
+ "node": ">=12"
66
+ }
67
+ },
68
+ "node_modules/@esbuild/android-arm": {
69
+ "version": "0.19.12",
70
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
71
+ "integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
72
+ "cpu": [
73
+ "arm"
74
+ ],
75
+ "optional": true,
76
+ "os": [
77
+ "android"
78
+ ],
79
+ "engines": {
80
+ "node": ">=12"
81
+ }
82
+ },
83
+ "node_modules/@esbuild/android-arm64": {
84
+ "version": "0.19.12",
85
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
86
+ "integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
87
+ "cpu": [
88
+ "arm64"
89
+ ],
90
+ "optional": true,
91
+ "os": [
92
+ "android"
93
+ ],
94
+ "engines": {
95
+ "node": ">=12"
96
+ }
97
+ },
98
+ "node_modules/@esbuild/android-x64": {
99
+ "version": "0.19.12",
100
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
101
+ "integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
102
+ "cpu": [
103
+ "x64"
104
+ ],
105
+ "optional": true,
106
+ "os": [
107
+ "android"
108
+ ],
109
+ "engines": {
110
+ "node": ">=12"
111
+ }
112
+ },
113
+ "node_modules/@esbuild/darwin-arm64": {
114
+ "version": "0.19.12",
115
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
116
+ "integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
117
+ "cpu": [
118
+ "arm64"
119
+ ],
120
+ "optional": true,
121
+ "os": [
122
+ "darwin"
123
+ ],
124
+ "engines": {
125
+ "node": ">=12"
126
+ }
127
+ },
128
+ "node_modules/@esbuild/darwin-x64": {
129
+ "version": "0.19.12",
130
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
131
+ "integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
132
+ "cpu": [
133
+ "x64"
134
+ ],
135
+ "optional": true,
136
+ "os": [
137
+ "darwin"
138
+ ],
139
+ "engines": {
140
+ "node": ">=12"
141
+ }
142
+ },
143
+ "node_modules/@esbuild/freebsd-arm64": {
144
+ "version": "0.19.12",
145
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
146
+ "integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
147
+ "cpu": [
148
+ "arm64"
149
+ ],
150
+ "optional": true,
151
+ "os": [
152
+ "freebsd"
153
+ ],
154
+ "engines": {
155
+ "node": ">=12"
156
+ }
157
+ },
158
+ "node_modules/@esbuild/freebsd-x64": {
159
+ "version": "0.19.12",
160
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
161
+ "integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
162
+ "cpu": [
163
+ "x64"
164
+ ],
165
+ "optional": true,
166
+ "os": [
167
+ "freebsd"
168
+ ],
169
+ "engines": {
170
+ "node": ">=12"
171
+ }
172
+ },
173
+ "node_modules/@esbuild/linux-arm": {
174
+ "version": "0.19.12",
175
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
176
+ "integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
177
+ "cpu": [
178
+ "arm"
179
+ ],
180
+ "optional": true,
181
+ "os": [
182
+ "linux"
183
+ ],
184
+ "engines": {
185
+ "node": ">=12"
186
+ }
187
+ },
188
+ "node_modules/@esbuild/linux-arm64": {
189
+ "version": "0.19.12",
190
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
191
+ "integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
192
+ "cpu": [
193
+ "arm64"
194
+ ],
195
+ "optional": true,
196
+ "os": [
197
+ "linux"
198
+ ],
199
+ "engines": {
200
+ "node": ">=12"
201
+ }
202
+ },
203
+ "node_modules/@esbuild/linux-ia32": {
204
+ "version": "0.19.12",
205
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
206
+ "integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
207
+ "cpu": [
208
+ "ia32"
209
+ ],
210
+ "optional": true,
211
+ "os": [
212
+ "linux"
213
+ ],
214
+ "engines": {
215
+ "node": ">=12"
216
+ }
217
+ },
218
+ "node_modules/@esbuild/linux-loong64": {
219
+ "version": "0.19.12",
220
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
221
+ "integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
222
+ "cpu": [
223
+ "loong64"
224
+ ],
225
+ "optional": true,
226
+ "os": [
227
+ "linux"
228
+ ],
229
+ "engines": {
230
+ "node": ">=12"
231
+ }
232
+ },
233
+ "node_modules/@esbuild/linux-mips64el": {
234
+ "version": "0.19.12",
235
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
236
+ "integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
237
+ "cpu": [
238
+ "mips64el"
239
+ ],
240
+ "optional": true,
241
+ "os": [
242
+ "linux"
243
+ ],
244
+ "engines": {
245
+ "node": ">=12"
246
+ }
247
+ },
248
+ "node_modules/@esbuild/linux-ppc64": {
249
+ "version": "0.19.12",
250
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
251
+ "integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
252
+ "cpu": [
253
+ "ppc64"
254
+ ],
255
+ "optional": true,
256
+ "os": [
257
+ "linux"
258
+ ],
259
+ "engines": {
260
+ "node": ">=12"
261
+ }
262
+ },
263
+ "node_modules/@esbuild/linux-riscv64": {
264
+ "version": "0.19.12",
265
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
266
+ "integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
267
+ "cpu": [
268
+ "riscv64"
269
+ ],
270
+ "optional": true,
271
+ "os": [
272
+ "linux"
273
+ ],
274
+ "engines": {
275
+ "node": ">=12"
276
+ }
277
+ },
278
+ "node_modules/@esbuild/linux-s390x": {
279
+ "version": "0.19.12",
280
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
281
+ "integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
282
+ "cpu": [
283
+ "s390x"
284
+ ],
285
+ "optional": true,
286
+ "os": [
287
+ "linux"
288
+ ],
289
+ "engines": {
290
+ "node": ">=12"
291
+ }
292
+ },
293
+ "node_modules/@esbuild/linux-x64": {
294
+ "version": "0.19.12",
295
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
296
+ "integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
297
+ "cpu": [
298
+ "x64"
299
+ ],
300
+ "optional": true,
301
+ "os": [
302
+ "linux"
303
+ ],
304
+ "engines": {
305
+ "node": ">=12"
306
+ }
307
+ },
308
+ "node_modules/@esbuild/netbsd-x64": {
309
+ "version": "0.19.12",
310
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
311
+ "integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
312
+ "cpu": [
313
+ "x64"
314
+ ],
315
+ "optional": true,
316
+ "os": [
317
+ "netbsd"
318
+ ],
319
+ "engines": {
320
+ "node": ">=12"
321
+ }
322
+ },
323
+ "node_modules/@esbuild/openbsd-x64": {
324
+ "version": "0.19.12",
325
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
326
+ "integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
327
+ "cpu": [
328
+ "x64"
329
+ ],
330
+ "optional": true,
331
+ "os": [
332
+ "openbsd"
333
+ ],
334
+ "engines": {
335
+ "node": ">=12"
336
+ }
337
+ },
338
+ "node_modules/@esbuild/sunos-x64": {
339
+ "version": "0.19.12",
340
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
341
+ "integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
342
+ "cpu": [
343
+ "x64"
344
+ ],
345
+ "optional": true,
346
+ "os": [
347
+ "sunos"
348
+ ],
349
+ "engines": {
350
+ "node": ">=12"
351
+ }
352
+ },
353
+ "node_modules/@esbuild/win32-arm64": {
354
+ "version": "0.19.12",
355
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
356
+ "integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
357
+ "cpu": [
358
+ "arm64"
359
+ ],
360
+ "optional": true,
361
+ "os": [
362
+ "win32"
363
+ ],
364
+ "engines": {
365
+ "node": ">=12"
366
+ }
367
+ },
368
+ "node_modules/@esbuild/win32-ia32": {
369
+ "version": "0.19.12",
370
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
371
+ "integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
372
+ "cpu": [
373
+ "ia32"
374
+ ],
375
+ "optional": true,
376
+ "os": [
377
+ "win32"
378
+ ],
379
+ "engines": {
380
+ "node": ">=12"
381
+ }
382
+ },
383
+ "node_modules/@esbuild/win32-x64": {
384
+ "version": "0.19.12",
385
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
386
+ "integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
387
+ "cpu": [
388
+ "x64"
389
+ ],
390
+ "optional": true,
391
+ "os": [
392
+ "win32"
393
+ ],
394
+ "engines": {
395
+ "node": ">=12"
396
+ }
397
+ },
398
+ "node_modules/@ffmpeg/ffmpeg": {
399
+ "version": "0.12.10",
400
+ "resolved": "https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.12.10.tgz",
401
+ "integrity": "sha512-lVtk8PW8e+NUzGZhPTWj2P1J4/NyuCrbDD3O9IGpSeLYtUZKBqZO8CNj1WYGghep/MXoM8e1qVY1GztTkf8YYQ==",
402
+ "dependencies": {
403
+ "@ffmpeg/types": "^0.12.2"
404
+ },
405
+ "engines": {
406
+ "node": ">=18.x"
407
+ }
408
+ },
409
+ "node_modules/@ffmpeg/types": {
410
+ "version": "0.12.2",
411
+ "resolved": "https://registry.npmjs.org/@ffmpeg/types/-/types-0.12.2.tgz",
412
+ "integrity": "sha512-NJtxwPoLb60/z1Klv0ueshguWQ/7mNm106qdHkB4HL49LXszjhjCCiL+ldHJGQ9ai2Igx0s4F24ghigy//ERdA==",
413
+ "engines": {
414
+ "node": ">=16.x"
415
+ }
416
+ },
417
+ "node_modules/@ffmpeg/util": {
418
+ "version": "0.12.1",
419
+ "resolved": "https://registry.npmjs.org/@ffmpeg/util/-/util-0.12.1.tgz",
420
+ "integrity": "sha512-10jjfAKWaDyb8+nAkijcsi9wgz/y26LOc1NKJradNMyCIl6usQcBbhkjX5qhALrSBcOy6TOeksunTYa+a03qNQ==",
421
+ "engines": {
422
+ "node": ">=18.x"
423
+ }
424
+ },
425
+ "node_modules/@formatjs/ecma402-abstract": {
426
+ "version": "1.11.4",
427
+ "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
428
+ "integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
429
+ "dependencies": {
430
+ "@formatjs/intl-localematcher": "0.2.25",
431
+ "tslib": "^2.1.0"
432
+ }
433
+ },
434
+ "node_modules/@formatjs/fast-memoize": {
435
+ "version": "1.2.1",
436
+ "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
437
+ "integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
438
+ "dependencies": {
439
+ "tslib": "^2.1.0"
440
+ }
441
+ },
442
+ "node_modules/@formatjs/icu-messageformat-parser": {
443
+ "version": "2.1.0",
444
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
445
+ "integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
446
+ "dependencies": {
447
+ "@formatjs/ecma402-abstract": "1.11.4",
448
+ "@formatjs/icu-skeleton-parser": "1.3.6",
449
+ "tslib": "^2.1.0"
450
+ }
451
+ },
452
+ "node_modules/@formatjs/icu-skeleton-parser": {
453
+ "version": "1.3.6",
454
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
455
+ "integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
456
+ "dependencies": {
457
+ "@formatjs/ecma402-abstract": "1.11.4",
458
+ "tslib": "^2.1.0"
459
+ }
460
+ },
461
+ "node_modules/@formatjs/intl-localematcher": {
462
+ "version": "0.2.25",
463
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
464
+ "integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
465
+ "dependencies": {
466
+ "tslib": "^2.1.0"
467
+ }
468
+ },
469
+ "node_modules/@gradio/atoms": {
470
+ "version": "0.5.3",
471
+ "resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.5.3.tgz",
472
+ "integrity": "sha512-1HZgmhbAPzCYt6muyttrJi/P5zXTnD3kVMgneXuDd2j9qB21kSqzshmpnPcvDO3lO0vro55HuxgH22PJ1XHWqg==",
473
+ "dependencies": {
474
+ "@gradio/icons": "^0.3.3",
475
+ "@gradio/utils": "^0.3.0"
476
+ }
477
+ },
478
+ "node_modules/@gradio/audio": {
479
+ "version": "0.9.6",
480
+ "resolved": "https://registry.npmjs.org/@gradio/audio/-/audio-0.9.6.tgz",
481
+ "integrity": "sha512-IiSYjU6u2azexhP7YoqCddCox16V66qXiygd7ogCzMyjiujhLJj8aUvjUnjvS6l/DtQ8ZeTnjgVwMkdHGBWSzA==",
482
+ "dependencies": {
483
+ "@gradio/atoms": "^0.5.3",
484
+ "@gradio/button": "^0.2.25",
485
+ "@gradio/client": "^0.13.0",
486
+ "@gradio/icons": "^0.3.3",
487
+ "@gradio/statustracker": "^0.4.8",
488
+ "@gradio/upload": "^0.7.7",
489
+ "@gradio/utils": "^0.3.0",
490
+ "@gradio/wasm": "^0.8.0",
491
+ "@types/wavesurfer.js": "^6.0.10",
492
+ "extendable-media-recorder": "^9.0.0",
493
+ "extendable-media-recorder-wav-encoder": "^7.0.76",
494
+ "resize-observer-polyfill": "^1.5.1",
495
+ "svelte-range-slider-pips": "^2.0.1",
496
+ "wavesurfer.js": "^7.4.2"
497
+ }
498
+ },
499
+ "node_modules/@gradio/button": {
500
+ "version": "0.2.29",
501
+ "resolved": "https://registry.npmjs.org/@gradio/button/-/button-0.2.29.tgz",
502
+ "integrity": "sha512-XHT+t54rj0yLTb/ECiQvTgTaTP0Qli09GyJzvpGDpgtITIncQxoALiYiKnD5ys6wZSPWdSuwIglyIJ7rn0vkKg==",
503
+ "dependencies": {
504
+ "@gradio/client": "^0.15.0",
505
+ "@gradio/upload": "^0.8.3",
506
+ "@gradio/utils": "^0.3.0"
507
+ }
508
+ },
509
+ "node_modules/@gradio/button/node_modules/@gradio/atoms": {
510
+ "version": "0.6.1",
511
+ "resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.6.1.tgz",
512
+ "integrity": "sha512-u7+cleKA0Et6AhEq5xTiaGIAYPR2He7/JSYcM3Sg+vkFOXhbJTPUnHLub+y9HiseheEmnZDGddFBr+RL5Jaxbg==",
513
+ "dependencies": {
514
+ "@gradio/icons": "^0.3.4",
515
+ "@gradio/utils": "^0.3.0"
516
+ }
517
+ },
518
+ "node_modules/@gradio/button/node_modules/@gradio/client": {
519
+ "version": "0.15.0",
520
+ "resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.15.0.tgz",
521
+ "integrity": "sha512-WQtLRy7mZYR07UsriSLHh3E/zwv53LzQGVCeEz6ue4YwsqEgaDrDwKIGjnpkL06HaZ94Gy/dAvZvUDI4MCO62g==",
522
+ "dependencies": {
523
+ "bufferutil": "^4.0.7",
524
+ "semiver": "^1.1.0",
525
+ "ws": "^8.13.0"
526
+ },
527
+ "engines": {
528
+ "node": ">=18.0.0"
529
+ }
530
+ },
531
+ "node_modules/@gradio/button/node_modules/@gradio/icons": {
532
+ "version": "0.3.4",
533
+ "resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.3.4.tgz",
534
+ "integrity": "sha512-rtH7u3OiYy9UuO1bnebXkTXgc+D62H6BILrMtM4EfsKGgQQICD0n7NPvbPtS0zpi/fz0ppCdlfFIKKIOeVaeFg=="
535
+ },
536
+ "node_modules/@gradio/button/node_modules/@gradio/upload": {
537
+ "version": "0.8.3",
538
+ "resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.8.3.tgz",
539
+ "integrity": "sha512-rufkvHPn1CwEuo/dgDMbSdLAG6m5poTT0hyDYnqdRkIAeBi6gU73xPylKUdQcVBIJvYGexkTU83jij4pnet6yQ==",
540
+ "dependencies": {
541
+ "@gradio/atoms": "^0.6.1",
542
+ "@gradio/client": "^0.15.0",
543
+ "@gradio/icons": "^0.3.4",
544
+ "@gradio/upload": "^0.8.3",
545
+ "@gradio/utils": "^0.3.0",
546
+ "@gradio/wasm": "^0.10.0"
547
+ }
548
+ },
549
+ "node_modules/@gradio/button/node_modules/@gradio/wasm": {
550
+ "version": "0.10.0",
551
+ "resolved": "https://registry.npmjs.org/@gradio/wasm/-/wasm-0.10.0.tgz",
552
+ "integrity": "sha512-ephuiuimvMad6KzNPz/3OdnjgE5wsJdVfAAqu+J0qloetbH42LfeRLsVe5WqGo2WpjzXq5MC8I8MJ7lpQMhUpw==",
553
+ "dependencies": {
554
+ "@types/path-browserify": "^1.0.0",
555
+ "path-browserify": "^1.0.1"
556
+ }
557
+ },
558
+ "node_modules/@gradio/client": {
559
+ "version": "0.13.0",
560
+ "resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.13.0.tgz",
561
+ "integrity": "sha512-TIkVkou3WvvPJIEasJ/JdR2F96OXfq8OkbChnkQLBtzuVHXuqfewqkDpK85Rw3lkPFofvp6jGrUGKd7imAq8ww==",
562
+ "dependencies": {
563
+ "bufferutil": "^4.0.7",
564
+ "semiver": "^1.1.0",
565
+ "ws": "^8.13.0"
566
+ },
567
+ "engines": {
568
+ "node": ">=18.0.0"
569
+ }
570
+ },
571
+ "node_modules/@gradio/column": {
572
+ "version": "0.1.0",
573
+ "resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
574
+ "integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
575
+ },
576
+ "node_modules/@gradio/icons": {
577
+ "version": "0.3.3",
578
+ "resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.3.3.tgz",
579
+ "integrity": "sha512-UFTHpjzFJVwaRzZsdslWxnKUPGgtVeErmUGzrG9di4Vn0oHn1FgHt1Yr2SVu4lO3JI/r2u3H49tb6iax4U9HjA=="
580
+ },
581
+ "node_modules/@gradio/image": {
582
+ "version": "0.9.6",
583
+ "resolved": "https://registry.npmjs.org/@gradio/image/-/image-0.9.6.tgz",
584
+ "integrity": "sha512-tFI9mRi0pradm+uqf1sSE0vRTKzklx923otbkj1RfqCmQ7f4M25pvYOcCpFALMVgMyUdAtjt86ARPsWyb4GS0w==",
585
+ "dependencies": {
586
+ "@gradio/atoms": "^0.5.3",
587
+ "@gradio/client": "^0.13.0",
588
+ "@gradio/icons": "^0.3.3",
589
+ "@gradio/statustracker": "^0.4.8",
590
+ "@gradio/upload": "^0.7.7",
591
+ "@gradio/utils": "^0.3.0",
592
+ "@gradio/wasm": "^0.8.0",
593
+ "cropperjs": "^1.5.12",
594
+ "lazy-brush": "^1.0.1",
595
+ "resize-observer-polyfill": "^1.5.1"
596
+ }
597
+ },
598
+ "node_modules/@gradio/markdown": {
599
+ "version": "0.6.5",
600
+ "resolved": "https://registry.npmjs.org/@gradio/markdown/-/markdown-0.6.5.tgz",
601
+ "integrity": "sha512-ae/hZiRg28n8uRs8MWwrfFwsT2NC/TFil178aAiXekj/w+tyFM3ZNqRCCHLj5IAjD8qASN7swNUSmWPM7ix1Gw==",
602
+ "dependencies": {
603
+ "@gradio/atoms": "^0.5.3",
604
+ "@gradio/statustracker": "^0.4.8",
605
+ "@gradio/utils": "^0.3.0",
606
+ "@types/dompurify": "^3.0.2",
607
+ "@types/katex": "^0.16.0",
608
+ "@types/prismjs": "1.26.3",
609
+ "dompurify": "^3.0.3",
610
+ "github-slugger": "^2.0.0",
611
+ "katex": "^0.16.7",
612
+ "marked": "^12.0.0",
613
+ "marked-gfm-heading-id": "^3.1.2",
614
+ "marked-highlight": "^2.0.1",
615
+ "prismjs": "1.29.0"
616
+ }
617
+ },
618
+ "node_modules/@gradio/statustracker": {
619
+ "version": "0.4.8",
620
+ "resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.4.8.tgz",
621
+ "integrity": "sha512-B/SN7T9BbcdzPrWYfKVxwy3e4u85MS+DAZSeuXgPbAL5n5QravCtvNW7zwkUWb0OlBloaglN3Y7K3M8l1hR5qg==",
622
+ "dependencies": {
623
+ "@gradio/atoms": "^0.5.3",
624
+ "@gradio/column": "^0.1.0",
625
+ "@gradio/icons": "^0.3.3",
626
+ "@gradio/utils": "^0.3.0"
627
+ }
628
+ },
629
+ "node_modules/@gradio/theme": {
630
+ "version": "0.2.0",
631
+ "resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.0.tgz",
632
+ "integrity": "sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ=="
633
+ },
634
+ "node_modules/@gradio/upload": {
635
+ "version": "0.7.7",
636
+ "resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.7.7.tgz",
637
+ "integrity": "sha512-U43AYVzlVieyHLgxZHLTwtnmja0n2IMY4q8REnsq9wP/lSYmbDMwanrkE6z7IJtRccc/qKriNUnJB02b2YIDtg==",
638
+ "dependencies": {
639
+ "@gradio/atoms": "^0.5.3",
640
+ "@gradio/client": "^0.13.0",
641
+ "@gradio/icons": "^0.3.3",
642
+ "@gradio/upload": "^0.7.7",
643
+ "@gradio/utils": "^0.3.0",
644
+ "@gradio/wasm": "^0.8.0"
645
+ }
646
+ },
647
+ "node_modules/@gradio/utils": {
648
+ "version": "0.3.0",
649
+ "resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.3.0.tgz",
650
+ "integrity": "sha512-VxP0h7UoWazkdSB875ChvTXWamBwMguuRc+8OyQFZjdj14lcqLEQuj54es3FDBpXOp5GMLFh48Q5FLLjYxMgSg==",
651
+ "dependencies": {
652
+ "@gradio/theme": "^0.2.0",
653
+ "svelte-i18n": "^3.6.0"
654
+ }
655
+ },
656
+ "node_modules/@gradio/video": {
657
+ "version": "0.6.6",
658
+ "resolved": "https://registry.npmjs.org/@gradio/video/-/video-0.6.6.tgz",
659
+ "integrity": "sha512-n9vYKELXWWTUUAahNkX7x6tUP9XApdnMChcanIOvdOXiyOiprJRMb9wRuChbz+E3IeJyEVS+qfgGdkN6bEkuvw==",
660
+ "dependencies": {
661
+ "@ffmpeg/ffmpeg": "^0.12.7",
662
+ "@ffmpeg/util": "^0.12.1",
663
+ "@gradio/atoms": "^0.5.3",
664
+ "@gradio/client": "^0.13.0",
665
+ "@gradio/icons": "^0.3.3",
666
+ "@gradio/image": "^0.9.6",
667
+ "@gradio/statustracker": "^0.4.8",
668
+ "@gradio/upload": "^0.7.7",
669
+ "@gradio/utils": "^0.3.0",
670
+ "@gradio/wasm": "^0.8.0",
671
+ "mrmime": "^2.0.0"
672
+ }
673
+ },
674
+ "node_modules/@gradio/wasm": {
675
+ "version": "0.8.0",
676
+ "resolved": "https://registry.npmjs.org/@gradio/wasm/-/wasm-0.8.0.tgz",
677
+ "integrity": "sha512-JZTboZPBffyCfZoY88NiQFDaB83zE7euP5dGL3Qw7mESmo/WPBiPj5QTm+EJd/ttxsxngQwO9YbHlFe2XiMk8g==",
678
+ "dependencies": {
679
+ "@types/path-browserify": "^1.0.0",
680
+ "path-browserify": "^1.0.1"
681
+ }
682
+ },
683
+ "node_modules/@jridgewell/gen-mapping": {
684
+ "version": "0.3.5",
685
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz",
686
+ "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
687
+ "peer": true,
688
+ "dependencies": {
689
+ "@jridgewell/set-array": "^1.2.1",
690
+ "@jridgewell/sourcemap-codec": "^1.4.10",
691
+ "@jridgewell/trace-mapping": "^0.3.24"
692
+ },
693
+ "engines": {
694
+ "node": ">=6.0.0"
695
+ }
696
+ },
697
+ "node_modules/@jridgewell/resolve-uri": {
698
+ "version": "3.1.2",
699
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
700
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
701
+ "peer": true,
702
+ "engines": {
703
+ "node": ">=6.0.0"
704
+ }
705
+ },
706
+ "node_modules/@jridgewell/set-array": {
707
+ "version": "1.2.1",
708
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",
709
+ "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
710
+ "peer": true,
711
+ "engines": {
712
+ "node": ">=6.0.0"
713
+ }
714
+ },
715
+ "node_modules/@jridgewell/sourcemap-codec": {
716
+ "version": "1.4.15",
717
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
718
+ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
719
+ "peer": true
720
+ },
721
+ "node_modules/@jridgewell/trace-mapping": {
722
+ "version": "0.3.25",
723
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
724
+ "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
725
+ "peer": true,
726
+ "dependencies": {
727
+ "@jridgewell/resolve-uri": "^3.1.0",
728
+ "@jridgewell/sourcemap-codec": "^1.4.14"
729
+ }
730
+ },
731
+ "node_modules/@types/debounce": {
732
+ "version": "1.2.4",
733
+ "resolved": "https://registry.npmjs.org/@types/debounce/-/debounce-1.2.4.tgz",
734
+ "integrity": "sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw=="
735
+ },
736
+ "node_modules/@types/dompurify": {
737
+ "version": "3.0.5",
738
+ "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.5.tgz",
739
+ "integrity": "sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==",
740
+ "dependencies": {
741
+ "@types/trusted-types": "*"
742
+ }
743
+ },
744
+ "node_modules/@types/estree": {
745
+ "version": "1.0.5",
746
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
747
+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
748
+ "peer": true
749
+ },
750
+ "node_modules/@types/katex": {
751
+ "version": "0.16.7",
752
+ "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
753
+ "integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ=="
754
+ },
755
+ "node_modules/@types/path-browserify": {
756
+ "version": "1.0.2",
757
+ "resolved": "https://registry.npmjs.org/@types/path-browserify/-/path-browserify-1.0.2.tgz",
758
+ "integrity": "sha512-ZkC5IUqqIFPXx3ASTTybTzmQdwHwe2C0u3eL75ldQ6T9E9IWFJodn6hIfbZGab73DfyiHN4Xw15gNxUq2FbvBA=="
759
+ },
760
+ "node_modules/@types/prismjs": {
761
+ "version": "1.26.3",
762
+ "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.3.tgz",
763
+ "integrity": "sha512-A0D0aTXvjlqJ5ZILMz3rNfDBOx9hHxLZYv2by47Sm/pqW35zzjusrZTryatjN/Rf8Us2gZrJD+KeHbUSTux1Cw=="
764
+ },
765
+ "node_modules/@types/trusted-types": {
766
+ "version": "2.0.7",
767
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
768
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
769
+ },
770
+ "node_modules/@types/wavesurfer.js": {
771
+ "version": "6.0.12",
772
+ "resolved": "https://registry.npmjs.org/@types/wavesurfer.js/-/wavesurfer.js-6.0.12.tgz",
773
+ "integrity": "sha512-oM9hYlPIVms4uwwoaGs9d0qp7Xk7IjSGkdwgmhUymVUIIilRfjtSQvoOgv4dpKiW0UozWRSyXfQqTobi0qWyCw==",
774
+ "dependencies": {
775
+ "@types/debounce": "*"
776
+ }
777
+ },
778
+ "node_modules/acorn": {
779
+ "version": "8.11.3",
780
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
781
+ "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
782
+ "peer": true,
783
+ "bin": {
784
+ "acorn": "bin/acorn"
785
+ },
786
+ "engines": {
787
+ "node": ">=0.4.0"
788
+ }
789
+ },
790
+ "node_modules/aria-query": {
791
+ "version": "5.3.0",
792
+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
793
+ "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
794
+ "peer": true,
795
+ "dependencies": {
796
+ "dequal": "^2.0.3"
797
+ }
798
+ },
799
+ "node_modules/automation-events": {
800
+ "version": "7.0.3",
801
+ "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-7.0.3.tgz",
802
+ "integrity": "sha512-5JhQDPpXvJLGgrDmr3xU9PX0ZxeJLZ1xJVkGmmRXkXNS/J9TSazLn/gu1s02qLI68RR40JpW6Uok9eaKtu4wBQ==",
803
+ "dependencies": {
804
+ "@babel/runtime": "^7.24.1",
805
+ "tslib": "^2.6.2"
806
+ },
807
+ "engines": {
808
+ "node": ">=18.2.0"
809
+ }
810
+ },
811
+ "node_modules/axobject-query": {
812
+ "version": "4.0.0",
813
+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.0.0.tgz",
814
+ "integrity": "sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==",
815
+ "peer": true,
816
+ "dependencies": {
817
+ "dequal": "^2.0.3"
818
+ }
819
+ },
820
+ "node_modules/broker-factory": {
821
+ "version": "3.0.96",
822
+ "resolved": "https://registry.npmjs.org/broker-factory/-/broker-factory-3.0.96.tgz",
823
+ "integrity": "sha512-wztvXRl5EnmsWpU6tWJX9K3oNyAsU2QN3RiK7Gsxz+wmIYRD9VBn+n/hH5alUKtTUROdxgs/KlnMTEGJuHAd4g==",
824
+ "dependencies": {
825
+ "@babel/runtime": "^7.24.1",
826
+ "fast-unique-numbers": "^9.0.3",
827
+ "tslib": "^2.6.2",
828
+ "worker-factory": "^7.0.23"
829
+ }
830
+ },
831
+ "node_modules/bufferutil": {
832
+ "version": "4.0.8",
833
+ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz",
834
+ "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==",
835
+ "hasInstallScript": true,
836
+ "dependencies": {
837
+ "node-gyp-build": "^4.3.0"
838
+ },
839
+ "engines": {
840
+ "node": ">=6.14.2"
841
+ }
842
+ },
843
+ "node_modules/cli-color": {
844
+ "version": "2.0.4",
845
+ "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
846
+ "integrity": "sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==",
847
+ "dependencies": {
848
+ "d": "^1.0.1",
849
+ "es5-ext": "^0.10.64",
850
+ "es6-iterator": "^2.0.3",
851
+ "memoizee": "^0.4.15",
852
+ "timers-ext": "^0.1.7"
853
+ },
854
+ "engines": {
855
+ "node": ">=0.10"
856
+ }
857
+ },
858
+ "node_modules/code-red": {
859
+ "version": "1.0.4",
860
+ "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
861
+ "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
862
+ "peer": true,
863
+ "dependencies": {
864
+ "@jridgewell/sourcemap-codec": "^1.4.15",
865
+ "@types/estree": "^1.0.1",
866
+ "acorn": "^8.10.0",
867
+ "estree-walker": "^3.0.3",
868
+ "periscopic": "^3.1.0"
869
+ }
870
+ },
871
+ "node_modules/commander": {
872
+ "version": "8.3.0",
873
+ "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
874
+ "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
875
+ "engines": {
876
+ "node": ">= 12"
877
+ }
878
+ },
879
+ "node_modules/cropperjs": {
880
+ "version": "1.6.1",
881
+ "resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.1.tgz",
882
+ "integrity": "sha512-F4wsi+XkDHCOMrHMYjrTEE4QBOrsHHN5/2VsVAaRq8P7E5z7xQpT75S+f/9WikmBEailas3+yo+6zPIomW+NOA=="
883
+ },
884
+ "node_modules/css-tree": {
885
+ "version": "2.3.1",
886
+ "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
887
+ "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
888
+ "peer": true,
889
+ "dependencies": {
890
+ "mdn-data": "2.0.30",
891
+ "source-map-js": "^1.0.1"
892
+ },
893
+ "engines": {
894
+ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
895
+ }
896
+ },
897
+ "node_modules/d": {
898
+ "version": "1.0.2",
899
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz",
900
+ "integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==",
901
+ "dependencies": {
902
+ "es5-ext": "^0.10.64",
903
+ "type": "^2.7.2"
904
+ },
905
+ "engines": {
906
+ "node": ">=0.12"
907
+ }
908
+ },
909
+ "node_modules/deepmerge": {
910
+ "version": "4.3.1",
911
+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
912
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
913
+ "engines": {
914
+ "node": ">=0.10.0"
915
+ }
916
+ },
917
+ "node_modules/dequal": {
918
+ "version": "2.0.3",
919
+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
920
+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
921
+ "engines": {
922
+ "node": ">=6"
923
+ }
924
+ },
925
+ "node_modules/dompurify": {
926
+ "version": "3.0.11",
927
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.11.tgz",
928
+ "integrity": "sha512-Fan4uMuyB26gFV3ovPoEoQbxRRPfTu3CvImyZnhGq5fsIEO+gEFLp45ISFt+kQBWsK5ulDdT0oV28jS1UrwQLg=="
929
+ },
930
+ "node_modules/es5-ext": {
931
+ "version": "0.10.64",
932
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz",
933
+ "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==",
934
+ "hasInstallScript": true,
935
+ "dependencies": {
936
+ "es6-iterator": "^2.0.3",
937
+ "es6-symbol": "^3.1.3",
938
+ "esniff": "^2.0.1",
939
+ "next-tick": "^1.1.0"
940
+ },
941
+ "engines": {
942
+ "node": ">=0.10"
943
+ }
944
+ },
945
+ "node_modules/es6-iterator": {
946
+ "version": "2.0.3",
947
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
948
+ "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
949
+ "dependencies": {
950
+ "d": "1",
951
+ "es5-ext": "^0.10.35",
952
+ "es6-symbol": "^3.1.1"
953
+ }
954
+ },
955
+ "node_modules/es6-symbol": {
956
+ "version": "3.1.4",
957
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz",
958
+ "integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==",
959
+ "dependencies": {
960
+ "d": "^1.0.2",
961
+ "ext": "^1.7.0"
962
+ },
963
+ "engines": {
964
+ "node": ">=0.12"
965
+ }
966
+ },
967
+ "node_modules/es6-weak-map": {
968
+ "version": "2.0.3",
969
+ "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
970
+ "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
971
+ "dependencies": {
972
+ "d": "1",
973
+ "es5-ext": "^0.10.46",
974
+ "es6-iterator": "^2.0.3",
975
+ "es6-symbol": "^3.1.1"
976
+ }
977
+ },
978
+ "node_modules/esbuild": {
979
+ "version": "0.19.12",
980
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
981
+ "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
982
+ "hasInstallScript": true,
983
+ "bin": {
984
+ "esbuild": "bin/esbuild"
985
+ },
986
+ "engines": {
987
+ "node": ">=12"
988
+ },
989
+ "optionalDependencies": {
990
+ "@esbuild/aix-ppc64": "0.19.12",
991
+ "@esbuild/android-arm": "0.19.12",
992
+ "@esbuild/android-arm64": "0.19.12",
993
+ "@esbuild/android-x64": "0.19.12",
994
+ "@esbuild/darwin-arm64": "0.19.12",
995
+ "@esbuild/darwin-x64": "0.19.12",
996
+ "@esbuild/freebsd-arm64": "0.19.12",
997
+ "@esbuild/freebsd-x64": "0.19.12",
998
+ "@esbuild/linux-arm": "0.19.12",
999
+ "@esbuild/linux-arm64": "0.19.12",
1000
+ "@esbuild/linux-ia32": "0.19.12",
1001
+ "@esbuild/linux-loong64": "0.19.12",
1002
+ "@esbuild/linux-mips64el": "0.19.12",
1003
+ "@esbuild/linux-ppc64": "0.19.12",
1004
+ "@esbuild/linux-riscv64": "0.19.12",
1005
+ "@esbuild/linux-s390x": "0.19.12",
1006
+ "@esbuild/linux-x64": "0.19.12",
1007
+ "@esbuild/netbsd-x64": "0.19.12",
1008
+ "@esbuild/openbsd-x64": "0.19.12",
1009
+ "@esbuild/sunos-x64": "0.19.12",
1010
+ "@esbuild/win32-arm64": "0.19.12",
1011
+ "@esbuild/win32-ia32": "0.19.12",
1012
+ "@esbuild/win32-x64": "0.19.12"
1013
+ }
1014
+ },
1015
+ "node_modules/esniff": {
1016
+ "version": "2.0.1",
1017
+ "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz",
1018
+ "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==",
1019
+ "dependencies": {
1020
+ "d": "^1.0.1",
1021
+ "es5-ext": "^0.10.62",
1022
+ "event-emitter": "^0.3.5",
1023
+ "type": "^2.7.2"
1024
+ },
1025
+ "engines": {
1026
+ "node": ">=0.10"
1027
+ }
1028
+ },
1029
+ "node_modules/estree-walker": {
1030
+ "version": "3.0.3",
1031
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
1032
+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
1033
+ "peer": true,
1034
+ "dependencies": {
1035
+ "@types/estree": "^1.0.0"
1036
+ }
1037
+ },
1038
+ "node_modules/event-emitter": {
1039
+ "version": "0.3.5",
1040
+ "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
1041
+ "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
1042
+ "dependencies": {
1043
+ "d": "1",
1044
+ "es5-ext": "~0.10.14"
1045
+ }
1046
+ },
1047
+ "node_modules/ext": {
1048
+ "version": "1.7.0",
1049
+ "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
1050
+ "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
1051
+ "dependencies": {
1052
+ "type": "^2.7.2"
1053
+ }
1054
+ },
1055
+ "node_modules/extendable-media-recorder": {
1056
+ "version": "9.1.13",
1057
+ "resolved": "https://registry.npmjs.org/extendable-media-recorder/-/extendable-media-recorder-9.1.13.tgz",
1058
+ "integrity": "sha512-viHMp1CQEFZ2q3UL/8avsmO5pb2WHXApip7TKikrmmLeBgvayIllvp4yy4wkMbtOQODIkLZYhoniRa4SVYwjkQ==",
1059
+ "dependencies": {
1060
+ "@babel/runtime": "^7.24.1",
1061
+ "media-encoder-host": "^8.0.112",
1062
+ "multi-buffer-data-view": "^6.0.3",
1063
+ "recorder-audio-worklet": "^6.0.24",
1064
+ "standardized-audio-context": "^25.3.68",
1065
+ "subscribable-things": "^2.1.34",
1066
+ "tslib": "^2.6.2"
1067
+ }
1068
+ },
1069
+ "node_modules/extendable-media-recorder-wav-encoder": {
1070
+ "version": "7.0.108",
1071
+ "resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder/-/extendable-media-recorder-wav-encoder-7.0.108.tgz",
1072
+ "integrity": "sha512-KVGezaqWwTO7ukaypDjgrb8UXs07m1H7tr7nVy91I0Dd3CID58U4TYqKDB2gXmJP5vqUr8/n1mrPaNTToNq4wA==",
1073
+ "dependencies": {
1074
+ "@babel/runtime": "^7.24.1",
1075
+ "extendable-media-recorder-wav-encoder-broker": "^7.0.99",
1076
+ "extendable-media-recorder-wav-encoder-worker": "^8.0.96",
1077
+ "tslib": "^2.6.2"
1078
+ }
1079
+ },
1080
+ "node_modules/extendable-media-recorder-wav-encoder-broker": {
1081
+ "version": "7.0.99",
1082
+ "resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-broker/-/extendable-media-recorder-wav-encoder-broker-7.0.99.tgz",
1083
+ "integrity": "sha512-K5rL3Ry+qQRWObB4En5Eiw8NL3DBRp5ThrOxtmtpvrZnDEaIuYBlIpmg3LF9RrFLyMhstj3z6Rd8hsNRp9hP1Q==",
1084
+ "dependencies": {
1085
+ "@babel/runtime": "^7.24.1",
1086
+ "broker-factory": "^3.0.96",
1087
+ "extendable-media-recorder-wav-encoder-worker": "^8.0.96",
1088
+ "tslib": "^2.6.2"
1089
+ }
1090
+ },
1091
+ "node_modules/extendable-media-recorder-wav-encoder-worker": {
1092
+ "version": "8.0.96",
1093
+ "resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-worker/-/extendable-media-recorder-wav-encoder-worker-8.0.96.tgz",
1094
+ "integrity": "sha512-zj/QbGr0SQLMGZuHCiv7WY6dUm2fhIhNbau1llVQDDvZe1aaqd+IUGai1y3qYRv+yg3lWI644fXI+4wsRWvATw==",
1095
+ "dependencies": {
1096
+ "@babel/runtime": "^7.24.1",
1097
+ "tslib": "^2.6.2",
1098
+ "worker-factory": "^7.0.23"
1099
+ }
1100
+ },
1101
+ "node_modules/fast-unique-numbers": {
1102
+ "version": "9.0.3",
1103
+ "resolved": "https://registry.npmjs.org/fast-unique-numbers/-/fast-unique-numbers-9.0.3.tgz",
1104
+ "integrity": "sha512-Aq5qOCVsmjsJbrGr4bxA3v3P1yQGBSUV2OobO2mE6jbux8fMPYbJlSgfZyXiLCy+Lo1NaK6UtbN2CTBSBt+AvA==",
1105
+ "dependencies": {
1106
+ "@babel/runtime": "^7.24.1",
1107
+ "tslib": "^2.6.2"
1108
+ },
1109
+ "engines": {
1110
+ "node": ">=18.2.0"
1111
+ }
1112
+ },
1113
+ "node_modules/github-slugger": {
1114
+ "version": "2.0.0",
1115
+ "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
1116
+ "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="
1117
+ },
1118
+ "node_modules/globalyzer": {
1119
+ "version": "0.1.0",
1120
+ "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
1121
+ "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
1122
+ },
1123
+ "node_modules/globrex": {
1124
+ "version": "0.1.2",
1125
+ "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
1126
+ "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
1127
+ },
1128
+ "node_modules/intl-messageformat": {
1129
+ "version": "9.13.0",
1130
+ "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
1131
+ "integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
1132
+ "dependencies": {
1133
+ "@formatjs/ecma402-abstract": "1.11.4",
1134
+ "@formatjs/fast-memoize": "1.2.1",
1135
+ "@formatjs/icu-messageformat-parser": "2.1.0",
1136
+ "tslib": "^2.1.0"
1137
+ }
1138
+ },
1139
+ "node_modules/is-promise": {
1140
+ "version": "2.2.2",
1141
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
1142
+ "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
1143
+ },
1144
+ "node_modules/is-reference": {
1145
+ "version": "3.0.2",
1146
+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
1147
+ "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
1148
+ "peer": true,
1149
+ "dependencies": {
1150
+ "@types/estree": "*"
1151
+ }
1152
+ },
1153
+ "node_modules/katex": {
1154
+ "version": "0.16.10",
1155
+ "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.10.tgz",
1156
+ "integrity": "sha512-ZiqaC04tp2O5utMsl2TEZTXxa6WSC4yo0fv5ML++D3QZv/vx2Mct0mTlRx3O+uUkjfuAgOkzsCmq5MiUEsDDdA==",
1157
+ "funding": [
1158
+ "https://opencollective.com/katex",
1159
+ "https://github.com/sponsors/katex"
1160
+ ],
1161
+ "dependencies": {
1162
+ "commander": "^8.3.0"
1163
+ },
1164
+ "bin": {
1165
+ "katex": "cli.js"
1166
+ }
1167
+ },
1168
+ "node_modules/lazy-brush": {
1169
+ "version": "1.0.1",
1170
+ "resolved": "https://registry.npmjs.org/lazy-brush/-/lazy-brush-1.0.1.tgz",
1171
+ "integrity": "sha512-xT/iSClTVi7vLoF8dCWTBhCuOWqsLXCMPa6ucVmVAk6hyNCM5JeS1NLhXqIrJktUg+caEYKlqSOUU4u3cpXzKg=="
1172
+ },
1173
+ "node_modules/locate-character": {
1174
+ "version": "3.0.0",
1175
+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
1176
+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
1177
+ "peer": true
1178
+ },
1179
+ "node_modules/lru-queue": {
1180
+ "version": "0.1.0",
1181
+ "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
1182
+ "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
1183
+ "dependencies": {
1184
+ "es5-ext": "~0.10.2"
1185
+ }
1186
+ },
1187
+ "node_modules/magic-string": {
1188
+ "version": "0.30.9",
1189
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.9.tgz",
1190
+ "integrity": "sha512-S1+hd+dIrC8EZqKyT9DstTH/0Z+f76kmmvZnkfQVmOpDEF9iVgdYif3Q/pIWHmCoo59bQVGW0kVL3e2nl+9+Sw==",
1191
+ "peer": true,
1192
+ "dependencies": {
1193
+ "@jridgewell/sourcemap-codec": "^1.4.15"
1194
+ },
1195
+ "engines": {
1196
+ "node": ">=12"
1197
+ }
1198
+ },
1199
+ "node_modules/marked": {
1200
+ "version": "12.0.1",
1201
+ "resolved": "https://registry.npmjs.org/marked/-/marked-12.0.1.tgz",
1202
+ "integrity": "sha512-Y1/V2yafOcOdWQCX0XpAKXzDakPOpn6U0YLxTJs3cww6VxOzZV1BTOOYWLvH3gX38cq+iLwljHHTnMtlDfg01Q==",
1203
+ "bin": {
1204
+ "marked": "bin/marked.js"
1205
+ },
1206
+ "engines": {
1207
+ "node": ">= 18"
1208
+ }
1209
+ },
1210
+ "node_modules/marked-gfm-heading-id": {
1211
+ "version": "3.1.3",
1212
+ "resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.1.3.tgz",
1213
+ "integrity": "sha512-A0cRU4PCueX/5m8VE4mT8uTQ36l3xMYRojz3Eqnk4BmUFZ0T+9Xhn2KvHcANP4qbhfOeuMrWJCTQbASIBR5xeg==",
1214
+ "dependencies": {
1215
+ "github-slugger": "^2.0.0"
1216
+ },
1217
+ "peerDependencies": {
1218
+ "marked": ">=4 <13"
1219
+ }
1220
+ },
1221
+ "node_modules/marked-highlight": {
1222
+ "version": "2.1.1",
1223
+ "resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.1.1.tgz",
1224
+ "integrity": "sha512-ktdqwtBne8rim5mb+vvZ9FzElGFb+CHCgkx/g6DSzTjaSrVnxsJdSzB5YgCkknFrcOW+viocM1lGyIjC0oa3fg==",
1225
+ "peerDependencies": {
1226
+ "marked": ">=4 <13"
1227
+ }
1228
+ },
1229
+ "node_modules/mdn-data": {
1230
+ "version": "2.0.30",
1231
+ "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
1232
+ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
1233
+ "peer": true
1234
+ },
1235
+ "node_modules/media-encoder-host": {
1236
+ "version": "8.0.112",
1237
+ "resolved": "https://registry.npmjs.org/media-encoder-host/-/media-encoder-host-8.0.112.tgz",
1238
+ "integrity": "sha512-9zzaN3Jg6rAAcwPYYvJMmluLB27U/kF6aJRXW4z3c039p8htnTXUN8ZilA02XEKQdOibu0EHNeF4w/nEAcQgYQ==",
1239
+ "dependencies": {
1240
+ "@babel/runtime": "^7.24.1",
1241
+ "media-encoder-host-broker": "^7.0.101",
1242
+ "media-encoder-host-worker": "^9.1.23",
1243
+ "tslib": "^2.6.2"
1244
+ }
1245
+ },
1246
+ "node_modules/media-encoder-host-broker": {
1247
+ "version": "7.0.101",
1248
+ "resolved": "https://registry.npmjs.org/media-encoder-host-broker/-/media-encoder-host-broker-7.0.101.tgz",
1249
+ "integrity": "sha512-lZ2jQelZK6omB5fc+AE87MHGFqdivAabuhf8trvcId4GTYXS7BQ2J+FDhpd5r9iVsfLAlOKyouC73NNthvVWfg==",
1250
+ "dependencies": {
1251
+ "@babel/runtime": "^7.24.1",
1252
+ "broker-factory": "^3.0.96",
1253
+ "fast-unique-numbers": "^9.0.3",
1254
+ "media-encoder-host-worker": "^9.1.23",
1255
+ "tslib": "^2.6.2"
1256
+ }
1257
+ },
1258
+ "node_modules/media-encoder-host-worker": {
1259
+ "version": "9.1.23",
1260
+ "resolved": "https://registry.npmjs.org/media-encoder-host-worker/-/media-encoder-host-worker-9.1.23.tgz",
1261
+ "integrity": "sha512-67s1Mu9irKwHRAYiaNJrDTJUsGrlwWrVhN9tNM47nieARli1ZPHtKJ39PV+Qgn5bfqK81UyHIVirN2xWd8i0oQ==",
1262
+ "dependencies": {
1263
+ "@babel/runtime": "^7.24.1",
1264
+ "extendable-media-recorder-wav-encoder-broker": "^7.0.99",
1265
+ "tslib": "^2.6.2",
1266
+ "worker-factory": "^7.0.23"
1267
+ }
1268
+ },
1269
+ "node_modules/memoizee": {
1270
+ "version": "0.4.15",
1271
+ "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
1272
+ "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
1273
+ "dependencies": {
1274
+ "d": "^1.0.1",
1275
+ "es5-ext": "^0.10.53",
1276
+ "es6-weak-map": "^2.0.3",
1277
+ "event-emitter": "^0.3.5",
1278
+ "is-promise": "^2.2.2",
1279
+ "lru-queue": "^0.1.0",
1280
+ "next-tick": "^1.1.0",
1281
+ "timers-ext": "^0.1.7"
1282
+ }
1283
+ },
1284
+ "node_modules/mri": {
1285
+ "version": "1.2.0",
1286
+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
1287
+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
1288
+ "engines": {
1289
+ "node": ">=4"
1290
+ }
1291
+ },
1292
+ "node_modules/mrmime": {
1293
+ "version": "2.0.0",
1294
+ "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz",
1295
+ "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==",
1296
+ "engines": {
1297
+ "node": ">=10"
1298
+ }
1299
+ },
1300
+ "node_modules/multi-buffer-data-view": {
1301
+ "version": "6.0.3",
1302
+ "resolved": "https://registry.npmjs.org/multi-buffer-data-view/-/multi-buffer-data-view-6.0.3.tgz",
1303
+ "integrity": "sha512-QxvFlGmLwLBkHfOvj+eUIAzTPFS3vuEAHsH7JJR7e8/VreLeUkC8lLfofOoIdm5u8BHEelMzh/6U/Zw6urFWEw==",
1304
+ "dependencies": {
1305
+ "@babel/runtime": "^7.24.1",
1306
+ "tslib": "^2.6.2"
1307
+ },
1308
+ "engines": {
1309
+ "node": ">=18.2.0"
1310
+ }
1311
+ },
1312
+ "node_modules/next-tick": {
1313
+ "version": "1.1.0",
1314
+ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
1315
+ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
1316
+ },
1317
+ "node_modules/node-gyp-build": {
1318
+ "version": "4.8.0",
1319
+ "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz",
1320
+ "integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==",
1321
+ "bin": {
1322
+ "node-gyp-build": "bin.js",
1323
+ "node-gyp-build-optional": "optional.js",
1324
+ "node-gyp-build-test": "build-test.js"
1325
+ }
1326
+ },
1327
+ "node_modules/path-browserify": {
1328
+ "version": "1.0.1",
1329
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
1330
+ "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g=="
1331
+ },
1332
+ "node_modules/periscopic": {
1333
+ "version": "3.1.0",
1334
+ "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
1335
+ "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
1336
+ "peer": true,
1337
+ "dependencies": {
1338
+ "@types/estree": "^1.0.0",
1339
+ "estree-walker": "^3.0.0",
1340
+ "is-reference": "^3.0.0"
1341
+ }
1342
+ },
1343
+ "node_modules/prismjs": {
1344
+ "version": "1.29.0",
1345
+ "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
1346
+ "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
1347
+ "engines": {
1348
+ "node": ">=6"
1349
+ }
1350
+ },
1351
+ "node_modules/recorder-audio-worklet": {
1352
+ "version": "6.0.24",
1353
+ "resolved": "https://registry.npmjs.org/recorder-audio-worklet/-/recorder-audio-worklet-6.0.24.tgz",
1354
+ "integrity": "sha512-ViX/TBwggm3YpRLLdR71+vbgOjHc9iEMXgV7ct46B3QexZ8Z+sPeuYiwc1Sxu3oALfPhvhKddrie3HqH8AXwCA==",
1355
+ "dependencies": {
1356
+ "@babel/runtime": "^7.24.1",
1357
+ "broker-factory": "^3.0.96",
1358
+ "fast-unique-numbers": "^9.0.3",
1359
+ "recorder-audio-worklet-processor": "^5.0.17",
1360
+ "standardized-audio-context": "^25.3.68",
1361
+ "subscribable-things": "^2.1.34",
1362
+ "tslib": "^2.6.2",
1363
+ "worker-factory": "^7.0.23"
1364
+ }
1365
+ },
1366
+ "node_modules/recorder-audio-worklet-processor": {
1367
+ "version": "5.0.17",
1368
+ "resolved": "https://registry.npmjs.org/recorder-audio-worklet-processor/-/recorder-audio-worklet-processor-5.0.17.tgz",
1369
+ "integrity": "sha512-5mtOpnpwyLcjUCicC88pDEpC+X7Ex/4kVqR0r+cAsmfRrMRbveaDe32mP/1RuZIuRk6bhuBndFC0XX8MatF9MA==",
1370
+ "dependencies": {
1371
+ "@babel/runtime": "^7.24.1",
1372
+ "tslib": "^2.6.2"
1373
+ }
1374
+ },
1375
+ "node_modules/regenerator-runtime": {
1376
+ "version": "0.14.1",
1377
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
1378
+ "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
1379
+ },
1380
+ "node_modules/resize-observer-polyfill": {
1381
+ "version": "1.5.1",
1382
+ "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
1383
+ "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
1384
+ },
1385
+ "node_modules/rxjs-interop": {
1386
+ "version": "2.0.0",
1387
+ "resolved": "https://registry.npmjs.org/rxjs-interop/-/rxjs-interop-2.0.0.tgz",
1388
+ "integrity": "sha512-ASEq9atUw7lualXB+knvgtvwkCEvGWV2gDD/8qnASzBkzEARZck9JAyxmY8OS6Nc1pCPEgDTKNcx+YqqYfzArw=="
1389
+ },
1390
+ "node_modules/sade": {
1391
+ "version": "1.8.1",
1392
+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
1393
+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
1394
+ "dependencies": {
1395
+ "mri": "^1.1.0"
1396
+ },
1397
+ "engines": {
1398
+ "node": ">=6"
1399
+ }
1400
+ },
1401
+ "node_modules/semiver": {
1402
+ "version": "1.1.0",
1403
+ "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
1404
+ "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
1405
+ "engines": {
1406
+ "node": ">=6"
1407
+ }
1408
+ },
1409
+ "node_modules/source-map-js": {
1410
+ "version": "1.2.0",
1411
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
1412
+ "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
1413
+ "peer": true,
1414
+ "engines": {
1415
+ "node": ">=0.10.0"
1416
+ }
1417
+ },
1418
+ "node_modules/standardized-audio-context": {
1419
+ "version": "25.3.68",
1420
+ "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.68.tgz",
1421
+ "integrity": "sha512-XxVOFwlnU3Rq7mfTpxRhuwgDf00HmG4GzpSRQcMwgoXLa+k/9n8HT9dpsLZt0A1YH+hO/kLxaBMOIv5fKV/Gcg==",
1422
+ "dependencies": {
1423
+ "@babel/runtime": "^7.24.1",
1424
+ "automation-events": "^7.0.3",
1425
+ "tslib": "^2.6.2"
1426
+ }
1427
+ },
1428
+ "node_modules/subscribable-things": {
1429
+ "version": "2.1.34",
1430
+ "resolved": "https://registry.npmjs.org/subscribable-things/-/subscribable-things-2.1.34.tgz",
1431
+ "integrity": "sha512-lQ+yAXc4XvQT/GyGh/Nlo0lFHXBK5teLW/FTFrbmmKX/DtMqpd7TPlsdNSIvV6EHuqhQoehdhNYMqDoN89WQ8A==",
1432
+ "dependencies": {
1433
+ "@babel/runtime": "^7.24.1",
1434
+ "rxjs-interop": "^2.0.0",
1435
+ "tslib": "^2.6.2"
1436
+ }
1437
+ },
1438
+ "node_modules/svelte": {
1439
+ "version": "4.2.12",
1440
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.12.tgz",
1441
+ "integrity": "sha512-d8+wsh5TfPwqVzbm4/HCXC783/KPHV60NvwitJnyTA5lWn1elhXMNWhXGCJ7PwPa8qFUnyJNIyuIRt2mT0WMug==",
1442
+ "peer": true,
1443
+ "dependencies": {
1444
+ "@ampproject/remapping": "^2.2.1",
1445
+ "@jridgewell/sourcemap-codec": "^1.4.15",
1446
+ "@jridgewell/trace-mapping": "^0.3.18",
1447
+ "@types/estree": "^1.0.1",
1448
+ "acorn": "^8.9.0",
1449
+ "aria-query": "^5.3.0",
1450
+ "axobject-query": "^4.0.0",
1451
+ "code-red": "^1.0.3",
1452
+ "css-tree": "^2.3.1",
1453
+ "estree-walker": "^3.0.3",
1454
+ "is-reference": "^3.0.1",
1455
+ "locate-character": "^3.0.0",
1456
+ "magic-string": "^0.30.4",
1457
+ "periscopic": "^3.1.0"
1458
+ },
1459
+ "engines": {
1460
+ "node": ">=16"
1461
+ }
1462
+ },
1463
+ "node_modules/svelte-i18n": {
1464
+ "version": "3.7.4",
1465
+ "resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
1466
+ "integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
1467
+ "dependencies": {
1468
+ "cli-color": "^2.0.3",
1469
+ "deepmerge": "^4.2.2",
1470
+ "esbuild": "^0.19.2",
1471
+ "estree-walker": "^2",
1472
+ "intl-messageformat": "^9.13.0",
1473
+ "sade": "^1.8.1",
1474
+ "tiny-glob": "^0.2.9"
1475
+ },
1476
+ "bin": {
1477
+ "svelte-i18n": "dist/cli.js"
1478
+ },
1479
+ "engines": {
1480
+ "node": ">= 16"
1481
+ },
1482
+ "peerDependencies": {
1483
+ "svelte": "^3 || ^4"
1484
+ }
1485
+ },
1486
+ "node_modules/svelte-i18n/node_modules/estree-walker": {
1487
+ "version": "2.0.2",
1488
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
1489
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
1490
+ },
1491
+ "node_modules/svelte-range-slider-pips": {
1492
+ "version": "2.3.1",
1493
+ "resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.3.1.tgz",
1494
+ "integrity": "sha512-P29PNqHld+SiaDuHzf98rLvhSYWXb3TVL9p7U5RG9UX8emUgypZgp9zuIIwpmIXysGQC6JG8duMc5FuaPnSVdg=="
1495
+ },
1496
+ "node_modules/timers-ext": {
1497
+ "version": "0.1.7",
1498
+ "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
1499
+ "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
1500
+ "dependencies": {
1501
+ "es5-ext": "~0.10.46",
1502
+ "next-tick": "1"
1503
+ }
1504
+ },
1505
+ "node_modules/tiny-glob": {
1506
+ "version": "0.2.9",
1507
+ "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
1508
+ "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
1509
+ "dependencies": {
1510
+ "globalyzer": "0.1.0",
1511
+ "globrex": "^0.1.2"
1512
+ }
1513
+ },
1514
+ "node_modules/tslib": {
1515
+ "version": "2.6.2",
1516
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
1517
+ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
1518
+ },
1519
+ "node_modules/type": {
1520
+ "version": "2.7.2",
1521
+ "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
1522
+ "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
1523
+ },
1524
+ "node_modules/wavesurfer.js": {
1525
+ "version": "7.7.8",
1526
+ "resolved": "https://registry.npmjs.org/wavesurfer.js/-/wavesurfer.js-7.7.8.tgz",
1527
+ "integrity": "sha512-uzpe+wOe031G03wC4P/LO7Ai9OkF7Wyh8QGn9IMjAbwtiwK+H083cOZij9S4SD/vEdTdXligFKvziSB9bVmaIg=="
1528
+ },
1529
+ "node_modules/worker-factory": {
1530
+ "version": "7.0.23",
1531
+ "resolved": "https://registry.npmjs.org/worker-factory/-/worker-factory-7.0.23.tgz",
1532
+ "integrity": "sha512-MqNAajaUNlfqlnj6S/vjN/eWdKfDodeEYwoi0ZDAmYeqFLVRaGuxIaXaAhtK+7cD4JtK9j6Y5h2nHoOYjSp5tg==",
1533
+ "dependencies": {
1534
+ "@babel/runtime": "^7.24.1",
1535
+ "fast-unique-numbers": "^9.0.3",
1536
+ "tslib": "^2.6.2"
1537
+ }
1538
+ },
1539
+ "node_modules/ws": {
1540
+ "version": "8.16.0",
1541
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz",
1542
+ "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
1543
+ "engines": {
1544
+ "node": ">=10.0.0"
1545
+ },
1546
+ "peerDependencies": {
1547
+ "bufferutil": "^4.0.1",
1548
+ "utf-8-validate": ">=5.0.2"
1549
+ },
1550
+ "peerDependenciesMeta": {
1551
+ "bufferutil": {
1552
+ "optional": true
1553
+ },
1554
+ "utf-8-validate": {
1555
+ "optional": true
1556
+ }
1557
+ }
1558
+ }
1559
+ }
1560
+ }
src/frontend/package.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_multimodalchatbot",
3
+ "version": "0.7.6",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "dependencies": {
10
+ "@gradio/atoms": "0.5.3",
11
+ "@gradio/audio": "0.9.6",
12
+ "@gradio/client": "0.13.0",
13
+ "@gradio/icons": "0.3.3",
14
+ "@gradio/image": "0.9.6",
15
+ "@gradio/markdown": "0.6.5",
16
+ "@gradio/statustracker": "0.4.8",
17
+ "@gradio/theme": "0.2.0",
18
+ "@gradio/upload": "0.7.7",
19
+ "@gradio/utils": "0.3.0",
20
+ "@gradio/video": "0.6.6",
21
+ "@types/dompurify": "^3.0.2",
22
+ "@types/katex": "^0.16.0",
23
+ "@types/prismjs": "1.26.3",
24
+ "dequal": "^2.0.2"
25
+ },
26
+ "main_changeset": true,
27
+ "main": "./Index.svelte",
28
+ "exports": {
29
+ ".": "./Index.svelte",
30
+ "./package.json": "./package.json"
31
+ }
32
+ }
src/frontend/shared/ChatBot.svelte ADDED
@@ -0,0 +1,582 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 { Audio } from "@gradio/audio/shared";
9
+ import { Image } from "@gradio/image/shared";
10
+ import { Video } from "@gradio/video/shared";
11
+ import type { SelectData, LikeData } from "@gradio/utils";
12
+ import { MarkdownCode as Markdown } from "@gradio/markdown";
13
+ import { type FileData } from "@gradio/client";
14
+ import Copy from "./Copy.svelte";
15
+ import type { I18nFormatter } from "js/app/src/gradio_helper";
16
+ import LikeDislike from "./LikeDislike.svelte";
17
+ import Pending from "./Pending.svelte";
18
+ import type { MultimodalMessage } from "./utils";
19
+
20
+ export let value:
21
+ | [
22
+ MultimodalMessage | null,
23
+ MultimodalMessage | null
24
+ ][]
25
+ | null;
26
+ let old_value:
27
+ | [
28
+ MultimodalMessage | null,
29
+ MultimodalMessage | null
30
+ ][]
31
+ | null = null;
32
+
33
+ export let latex_delimiters: {
34
+ left: string;
35
+ right: string;
36
+ display: boolean;
37
+ }[];
38
+ export let pending_message = false;
39
+ export let selectable = false;
40
+ export let likeable = false;
41
+ export let show_share_button = false;
42
+ export let rtl = false;
43
+ export let show_copy_button = false;
44
+ export let avatar_images: [FileData | null, FileData | null] = [null, null];
45
+ export let sanitize_html = true;
46
+ export let bubble_full_width = true;
47
+ export let render_markdown = true;
48
+ export let line_breaks = true;
49
+ export let i18n: I18nFormatter;
50
+ export let layout: "bubble" | "panel" = "bubble";
51
+
52
+ let div: HTMLDivElement;
53
+ let autoscroll: boolean;
54
+
55
+ $: adjust_text_size = () => {
56
+ let style = getComputedStyle(document.body);
57
+ let body_text_size = style.getPropertyValue("--body-text-size");
58
+ let updated_text_size;
59
+
60
+ switch (body_text_size) {
61
+ case "13px":
62
+ updated_text_size = 14;
63
+ break;
64
+ case "14px":
65
+ updated_text_size = 16;
66
+ break;
67
+ case "16px":
68
+ updated_text_size = 20;
69
+ break;
70
+ default:
71
+ updated_text_size = 14;
72
+ break;
73
+ }
74
+
75
+ document.body.style.setProperty(
76
+ "--chatbot-body-text-size",
77
+ updated_text_size + "px"
78
+ );
79
+ };
80
+
81
+ $: adjust_text_size();
82
+
83
+ const dispatch = createEventDispatcher<{
84
+ change: undefined;
85
+ select: SelectData;
86
+ like: LikeData;
87
+ }>();
88
+
89
+ beforeUpdate(() => {
90
+ autoscroll =
91
+ div && div.offsetHeight + div.scrollTop > div.scrollHeight - 100;
92
+ });
93
+
94
+ const scroll = (): void => {
95
+ if (autoscroll) {
96
+ div.scrollTo(0, div.scrollHeight);
97
+ }
98
+ };
99
+ afterUpdate(() => {
100
+ if (autoscroll) {
101
+ scroll();
102
+ div.querySelectorAll("img").forEach((n) => {
103
+ n.addEventListener("load", () => {
104
+ scroll();
105
+ });
106
+ });
107
+ }
108
+ });
109
+
110
+ $: {
111
+ if (!dequal(value, old_value)) {
112
+ old_value = value;
113
+ dispatch("change");
114
+ }
115
+ }
116
+
117
+ function handle_select(
118
+ i: number,
119
+ j: number,
120
+ message: MultimodalMessage | null
121
+ ): void {
122
+ dispatch("select", {
123
+ index: [i, j],
124
+ value: message
125
+ });
126
+ }
127
+
128
+ function handle_like(
129
+ i: number,
130
+ j: number,
131
+ message: MultimodalMessage | null,
132
+ selected: boolean
133
+ ): void {
134
+ dispatch("like", {
135
+ index: [i, j],
136
+ value: message,
137
+ liked: liked
138
+ });
139
+ }
140
+ </script>
141
+
142
+ {#if show_share_button && value !== null && value.length > 0}
143
+ <div class="share-button">
144
+ <ShareButton
145
+ {i18n}
146
+ on:error
147
+ on:share
148
+ formatter={format_chat_for_sharing}
149
+ {value}
150
+ />
151
+ </div>
152
+ {/if}
153
+
154
+ <div
155
+ class={layout === "bubble" ? "bubble-wrap" : "panel-wrap"}
156
+ bind:this={div}
157
+ role="log"
158
+ aria-label="chatbot conversation"
159
+ aria-live="polite"
160
+ >
161
+ <div class="message-wrap" class:bubble-gap={layout === "bubble"} use:copy>
162
+ {#if value !== null}
163
+ {#each value as message_pair, i}
164
+ {#each message_pair as message, j}
165
+ {#if message !== null}
166
+ <div class="message-row {layout} {j == 0 ? 'user-row' : 'bot-row'}">
167
+ {#if avatar_images[j] !== null}
168
+ <div class="avatar-container">
169
+ <Image
170
+ class="avatar-image"
171
+ src={avatar_images[j]?.url}
172
+ alt="{j == 0 ? 'user' : 'bot'} avatar"
173
+ />
174
+ </div>
175
+ {/if}
176
+
177
+ <div
178
+ class="message {j == 0 ? 'user' : 'bot'}"
179
+ class:message-fit={layout === "bubble" && !bubble_full_width}
180
+ class:panel-full-width={layout === "panel"}
181
+ class:message-bubble-border={layout === "bubble"}
182
+ class:message-markdown-disabled={!render_markdown}
183
+ style:text-align={rtl && j == 0 ? "left" : "right"}
184
+ >
185
+ <button
186
+ data-testid={j == 0 ? "user" : "bot"}
187
+ class:latest={i === value.length - 1}
188
+ class:message-markdown-disabled={!render_markdown}
189
+ style:user-select="text"
190
+ class:selectable
191
+ style:text-align={rtl ? "right" : "left"}
192
+ on:click={() => handle_select(i, j, message)}
193
+ on:keydown={(e) => {
194
+ if (e.key === "Enter") {
195
+ handle_select(i, j, message);
196
+ }
197
+ }}
198
+ dir={rtl ? "rtl" : "ltr"}
199
+ aria-label={(j == 0 ? "user" : "bot") +
200
+ "'s message: " +
201
+ (typeof message === "string"
202
+ ? message
203
+ : `a file of type ${message.file?.mime_type}, ${
204
+ message.file?.alt_text ??
205
+ message.file?.orig_name ??
206
+ ""
207
+ }`)}
208
+ >
209
+ <Markdown
210
+ message={message.text}
211
+ {latex_delimiters}
212
+ {sanitize_html}
213
+ {render_markdown}
214
+ {line_breaks}
215
+ on:load={scroll}
216
+ />
217
+ {#each message.files as file, k}
218
+ {#if file !== null && file.file.mime_type?.includes("audio")}
219
+ <audio
220
+ data-testid="chatbot-audio"
221
+ controls
222
+ preload="metadata"
223
+ src={file.file?.url}
224
+ title={file.alt_text}
225
+ on:play
226
+ on:pause
227
+ on:ended
228
+ />
229
+ {:else if message !== null && file.file?.mime_type?.includes("video")}
230
+ <video
231
+ data-testid="chatbot-video"
232
+ controls
233
+ src={file.file?.url}
234
+ title={file.alt_text}
235
+ preload="auto"
236
+ on:play
237
+ on:pause
238
+ on:ended
239
+ >
240
+ <track kind="captions" />
241
+ </video>
242
+ {:else if message !== null && file.file?.mime_type?.includes("image")}
243
+ <img
244
+ data-testid="chatbot-image"
245
+ src={file.file?.url}
246
+ alt={file.alt_text}
247
+ />
248
+ {:else if message !== null && file.file?.url !== null}
249
+ <a
250
+ data-testid="chatbot-file"
251
+ href={file.file?.url}
252
+ target="_blank"
253
+ download={window.__is_colab__
254
+ ? null
255
+ : file.file?.orig_name || file.file?.path}
256
+ >
257
+ {file.file?.orig_name || file.file?.path}
258
+ </a>
259
+ {:else if pending_message && j === 1}
260
+ <Pending {layout} />
261
+ {/if}
262
+ {/each}
263
+ </button>
264
+ </div>
265
+ {#if (likeable && j !== 0) || (show_copy_button && message && typeof message === "string")}
266
+ <div
267
+ class="message-buttons-{j == 0
268
+ ? 'user'
269
+ : 'bot'} message-buttons-{layout} {avatar_images[j] !==
270
+ null && 'with-avatar'}"
271
+ class:message-buttons-fit={layout === "bubble" &&
272
+ !bubble_full_width}
273
+ class:bubble-buttons-user={layout === "bubble"}
274
+ >
275
+ {#if likeable && j == 1}
276
+ <LikeDislike
277
+ handle_action={(selected) =>
278
+ handle_like(i, j, message, selected)}
279
+ />
280
+ {/if}
281
+ {#if show_copy_button && message && typeof message === "string"}
282
+ <Copy value={message} />
283
+ {/if}
284
+ </div>
285
+ {/if}
286
+ </div>
287
+ {/if}
288
+ {/each}
289
+ {/each}
290
+ {#if pending_message}
291
+ <Pending {layout} />
292
+ {/if}
293
+ {/if}
294
+ </div>
295
+ </div>
296
+
297
+ <style>
298
+ .bubble-wrap {
299
+ padding: var(--block-padding);
300
+ width: 100%;
301
+ overflow-y: auto;
302
+ }
303
+
304
+ .panel-wrap {
305
+ width: 100%;
306
+ overflow-y: auto;
307
+ }
308
+
309
+ .message-wrap {
310
+ display: flex;
311
+ flex-direction: column;
312
+ justify-content: space-between;
313
+ }
314
+
315
+ .bubble-gap {
316
+ gap: calc(var(--spacing-xxl) + var(--spacing-lg));
317
+ }
318
+
319
+ .message-wrap > div :not(.avatar-container) :global(img) {
320
+ border-radius: 13px;
321
+ max-width: 30vw;
322
+ }
323
+
324
+ .message-wrap > div :global(p:not(:first-child)) {
325
+ margin-top: var(--spacing-xxl);
326
+ }
327
+
328
+ .message {
329
+ position: relative;
330
+ display: flex;
331
+ flex-direction: column;
332
+ align-self: flex-end;
333
+ background: var(--background-fill-secondary);
334
+ width: calc(100% - var(--spacing-xxl));
335
+ color: var(--body-text-color);
336
+ font-size: var(--chatbot-body-text-size);
337
+ overflow-wrap: break-word;
338
+ overflow-x: hidden;
339
+ padding-right: calc(var(--spacing-xxl) + var(--spacing-md));
340
+ padding: calc(var(--spacing-xxl) + var(--spacing-sm));
341
+ }
342
+
343
+ .message-bubble-border {
344
+ border-width: 1px;
345
+ border-radius: var(--radius-xxl);
346
+ }
347
+
348
+ .message-fit {
349
+ width: fit-content !important;
350
+ }
351
+
352
+ .panel-full-width {
353
+ padding: calc(var(--spacing-xxl) * 2);
354
+ width: 100%;
355
+ }
356
+ .message-markdown-disabled {
357
+ white-space: pre-line;
358
+ }
359
+
360
+ @media (max-width: 480px) {
361
+ .panel-full-width {
362
+ padding: calc(var(--spacing-xxl) * 2);
363
+ }
364
+ }
365
+
366
+ .user {
367
+ align-self: flex-start;
368
+ border-bottom-right-radius: 0;
369
+ text-align: right;
370
+ }
371
+ .bot {
372
+ border-bottom-left-radius: 0;
373
+ text-align: left;
374
+ }
375
+
376
+ /* Colors */
377
+ .bot {
378
+ border-color: var(--border-color-primary);
379
+ background: var(--background-fill-secondary);
380
+ }
381
+
382
+ .user {
383
+ border-color: var(--border-color-accent-subdued);
384
+ background-color: var(--color-accent-soft);
385
+ }
386
+ .message-row {
387
+ display: flex;
388
+ flex-direction: row;
389
+ position: relative;
390
+ }
391
+
392
+ .message-row.panel.user-row {
393
+ background: var(--color-accent-soft);
394
+ }
395
+
396
+ .message-row.panel.bot-row {
397
+ background: var(--background-fill-secondary);
398
+ }
399
+
400
+ .message-row:last-of-type {
401
+ margin-bottom: var(--spacing-xxl);
402
+ }
403
+
404
+ .user-row.bubble {
405
+ flex-direction: row;
406
+ justify-content: flex-end;
407
+ }
408
+ @media (max-width: 480px) {
409
+ .user-row.bubble {
410
+ align-self: flex-end;
411
+ }
412
+
413
+ .bot-row.bubble {
414
+ align-self: flex-start;
415
+ }
416
+ .message {
417
+ width: auto;
418
+ }
419
+ }
420
+ .avatar-container {
421
+ align-self: flex-end;
422
+ position: relative;
423
+ justify-content: center;
424
+ width: 35px;
425
+ height: 35px;
426
+ flex-shrink: 0;
427
+ bottom: 0;
428
+ }
429
+ .user-row.bubble > .avatar-container {
430
+ order: 2;
431
+ margin-left: 10px;
432
+ }
433
+ .bot-row.bubble > .avatar-container {
434
+ margin-right: 10px;
435
+ }
436
+
437
+ .panel > .avatar-container {
438
+ margin-left: 25px;
439
+ align-self: center;
440
+ }
441
+
442
+ .avatar-container :global(img) {
443
+ width: 100%;
444
+ height: 100%;
445
+ object-fit: cover;
446
+ border-radius: 50%;
447
+ }
448
+
449
+ .message-buttons-user,
450
+ .message-buttons-bot {
451
+ border-radius: var(--radius-md);
452
+ display: flex;
453
+ align-items: center;
454
+ bottom: 0;
455
+ height: var(--size-7);
456
+ align-self: self-end;
457
+ position: absolute;
458
+ bottom: -15px;
459
+ margin: 2px;
460
+ padding-left: 5px;
461
+ z-index: 1;
462
+ }
463
+ .message-buttons-bot {
464
+ left: 10px;
465
+ }
466
+ .message-buttons-user {
467
+ right: 5px;
468
+ }
469
+
470
+ .message-buttons-bot.message-buttons-bubble.with-avatar {
471
+ left: 50px;
472
+ }
473
+ .message-buttons-user.message-buttons-bubble.with-avatar {
474
+ right: 50px;
475
+ }
476
+
477
+ .message-buttons-bubble {
478
+ border: 1px solid var(--border-color-accent);
479
+ background: var(--background-fill-secondary);
480
+ }
481
+
482
+ .message-buttons-panel {
483
+ left: unset;
484
+ right: 0px;
485
+ top: 0px;
486
+ }
487
+
488
+ .share-button {
489
+ position: absolute;
490
+ top: 4px;
491
+ right: 6px;
492
+ }
493
+
494
+ .selectable {
495
+ cursor: pointer;
496
+ }
497
+
498
+ @keyframes dot-flashing {
499
+ 0% {
500
+ opacity: 0.8;
501
+ }
502
+ 50% {
503
+ opacity: 0.5;
504
+ }
505
+ 100% {
506
+ opacity: 0.8;
507
+ }
508
+ }
509
+ .message-wrap .message :global(img) {
510
+ margin: var(--size-2);
511
+ max-height: 200px;
512
+ }
513
+ .message-wrap .message :global(a) {
514
+ color: var(--color-text-link);
515
+ text-decoration: underline;
516
+ }
517
+
518
+ .message-wrap .bot :global(table),
519
+ .message-wrap .bot :global(tr),
520
+ .message-wrap .bot :global(td),
521
+ .message-wrap .bot :global(th) {
522
+ border: 1px solid var(--border-color-primary);
523
+ }
524
+
525
+ .message-wrap .user :global(table),
526
+ .message-wrap .user :global(tr),
527
+ .message-wrap .user :global(td),
528
+ .message-wrap .user :global(th) {
529
+ border: 1px solid var(--border-color-accent);
530
+ }
531
+
532
+ /* Lists */
533
+ .message-wrap :global(ol),
534
+ .message-wrap :global(ul) {
535
+ padding-inline-start: 2em;
536
+ }
537
+
538
+ /* KaTeX */
539
+ .message-wrap :global(span.katex) {
540
+ font-size: var(--text-lg);
541
+ direction: ltr;
542
+ }
543
+
544
+ /* Copy button */
545
+ .message-wrap :global(div[class*="code_wrap"] > button) {
546
+ position: absolute;
547
+ top: var(--spacing-md);
548
+ right: var(--spacing-md);
549
+ z-index: 1;
550
+ cursor: pointer;
551
+ border-bottom-left-radius: var(--radius-sm);
552
+ padding: 5px;
553
+ padding: var(--spacing-md);
554
+ width: 25px;
555
+ height: 25px;
556
+ }
557
+
558
+ .message-wrap :global(code > button > span) {
559
+ position: absolute;
560
+ top: var(--spacing-md);
561
+ right: var(--spacing-md);
562
+ width: 12px;
563
+ height: 12px;
564
+ }
565
+ .message-wrap :global(.check) {
566
+ position: absolute;
567
+ top: 0;
568
+ right: 0;
569
+ opacity: 0;
570
+ z-index: var(--layer-top);
571
+ transition: opacity 0.2s;
572
+ background: var(--background-fill-primary);
573
+ padding: var(--size-1);
574
+ width: 100%;
575
+ height: 100%;
576
+ color: var(--body-text-color);
577
+ }
578
+
579
+ .message-wrap :global(pre) {
580
+ position: relative;
581
+ }
582
+ </style>
src/frontend/shared/Copy.svelte ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class="action"
50
+ title="copy"
51
+ aria-label={copied ? "Copied message" : "Copy message"}
52
+ >
53
+ {#if !copied}
54
+ <Copy />
55
+ {/if}
56
+ {#if copied}
57
+ <Check />
58
+ {/if}
59
+ </button>
60
+
61
+ <style>
62
+ button {
63
+ position: relative;
64
+ top: 0;
65
+ right: 0;
66
+ cursor: pointer;
67
+ color: var(--body-text-color-subdued);
68
+ margin-right: 5px;
69
+ }
70
+
71
+ button:hover {
72
+ color: var(--body-text-color);
73
+ }
74
+
75
+ .action {
76
+ width: 15px;
77
+ height: 14px;
78
+ }
79
+ </style>
src/frontend/shared/LikeDislike.svelte ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Like } from "@gradio/icons";
3
+ import { Dislike } from "@gradio/icons";
4
+
5
+ export let handle_action: (selected: string | null) => void;
6
+
7
+ let selected: "like" | "dislike" | null = null;
8
+ </script>
9
+
10
+ <button
11
+ on:click={() => {
12
+ selected = "like";
13
+ handle_action(selected);
14
+ }}
15
+ aria-label={selected === "like" ? "clicked like" : "like"}
16
+ >
17
+ <Like selected={selected === "like"} />
18
+ </button>
19
+
20
+ <button
21
+ on:click={() => {
22
+ selected = "dislike";
23
+ handle_action(selected);
24
+ }}
25
+ aria-label={selected === "dislike" ? "clicked dislike" : "dislike"}
26
+ >
27
+ <Dislike selected={selected === "dislike"} />
28
+ </button>
29
+
30
+ <style>
31
+ button {
32
+ position: relative;
33
+ top: 0;
34
+ right: 0;
35
+ cursor: pointer;
36
+ color: var(--body-text-color-subdued);
37
+ width: 17px;
38
+ height: 17px;
39
+ margin-right: 5px;
40
+ }
41
+
42
+ button:hover,
43
+ button:focus {
44
+ color: var(--body-text-color);
45
+ }
46
+ </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
+ &nbsp;
15
+ <div class="dot-flashing" />
16
+ &nbsp;
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,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { FileData } from "@gradio/client";
2
+ import { uploadToHuggingFace } from "@gradio/utils";
3
+
4
+ export type FileMessage = {
5
+ file: FileData;
6
+ alt_text?: string;
7
+ };
8
+
9
+
10
+ export type MultimodalMessage = {
11
+ text: string;
12
+ files?: FileMessage[];
13
+ }
14
+
15
+ export const format_chat_for_sharing = async (
16
+ chat: [string | FileData | null, string | FileData | null][]
17
+ ): Promise<string> => {
18
+ let messages = await Promise.all(
19
+ chat.map(async (message_pair) => {
20
+ return await Promise.all(
21
+ message_pair.map(async (message, i) => {
22
+ if (message === null) return "";
23
+ let speaker_emoji = i === 0 ? "😃" : "🤖";
24
+ let html_content = "";
25
+
26
+ if (typeof message === "string") {
27
+ const regexPatterns = {
28
+ audio: /<audio.*?src="(\/file=.*?)"/g,
29
+ video: /<video.*?src="(\/file=.*?)"/g,
30
+ image: /<img.*?src="(\/file=.*?)".*?\/>|!\[.*?\]\((\/file=.*?)\)/g
31
+ };
32
+
33
+ html_content = message;
34
+
35
+ for (let [_, regex] of Object.entries(regexPatterns)) {
36
+ let match;
37
+
38
+ while ((match = regex.exec(message)) !== null) {
39
+ const fileUrl = match[1] || match[2];
40
+ const newUrl = await uploadToHuggingFace(fileUrl, "url");
41
+ html_content = html_content.replace(fileUrl, newUrl);
42
+ }
43
+ }
44
+ } else {
45
+ if (!message?.url) return "";
46
+ const file_url = await uploadToHuggingFace(message.url, "url");
47
+ if (message.mime_type?.includes("audio")) {
48
+ html_content = `<audio controls src="${file_url}"></audio>`;
49
+ } else if (message.mime_type?.includes("video")) {
50
+ html_content = file_url;
51
+ } else if (message.mime_type?.includes("image")) {
52
+ html_content = `<img src="${file_url}" />`;
53
+ }
54
+ }
55
+
56
+ return `${speaker_emoji}: ${html_content}`;
57
+ })
58
+ );
59
+ })
60
+ );
61
+ return messages
62
+ .map((message_pair) =>
63
+ message_pair.join(
64
+ message_pair[0] !== "" && message_pair[1] !== "" ? "\n" : ""
65
+ )
66
+ )
67
+ .join("\n");
68
+ };
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_awsbr_mmchatbot"
11
+ version = "0.0.2"
12
+ description = "This component enables multi-modal input for the Anthropic Claude v3 suite of models available from Amazon Bedrock"
13
+ readme = "README.md"
14
+ license = "MIT"
15
+ requires-python = ">=3.8"
16
+ authors = [{ name = "Jedijamez", email = "" }]
17
+ keywords = ["gradio-custom-component", "gradio-template-Chatbot", "AWS", "Bedrock", "Amazon Bedrock", "Anthropic", "LLM", "Chatbot", "Multimodal", "Claude", "Claude v3"]
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_multimodalchatbot/templates", "*.pyi", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_multimodalchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates", "backend/gradio_awsbr_mmchatbot/templates"]
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["/backend/gradio_multimodalchatbot"]