Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- README.md +11 -5
- app.py +1 -0
- docs.md +10 -4
- requirements.txt +1 -1
- src/LICENSE +201 -0
- src/README.md +12 -6
- src/backend/gradio_agentchatbot/templates/component/index.js +96 -104
- src/backend/gradio_agentchatbot/utils.py +0 -1
- src/demo/app.py +1 -0
- src/demo/docs.md +10 -4
- src/demo/requirements.txt +3 -2
- src/frontend/shared/ChatBot.svelte +10 -9
- src/frontend/types.ts +1 -2
- src/pyproject.toml +1 -1
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
tags: [gradio-custom-component, Chatbot, chatbot, agents, streaming, tools]
|
3 |
title: gradio_agentchatbot
|
4 |
-
short_description: Chat with agents and see
|
5 |
colorFrom: blue
|
6 |
colorTo: yellow
|
7 |
sdk: gradio
|
@@ -80,7 +80,7 @@ if __name__ == "__main__":
|
|
80 |
|
81 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
82 |
|
83 |
-
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how
|
84 |
|
85 |
```python
|
86 |
class ThoughtMetadata(GradioModel):
|
@@ -91,14 +91,12 @@ class ThoughtMetadata(GradioModel):
|
|
91 |
class ChatMessage(GradioModel):
|
92 |
role: Literal["user", "assistant"]
|
93 |
content: str
|
94 |
-
thought: bool = False
|
95 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
96 |
|
97 |
|
98 |
class ChatFileMessage(GradioModel):
|
99 |
role: Literal["user", "assistant"]
|
100 |
file: FileData
|
101 |
-
thought: bool = False
|
102 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
103 |
alt_text: Optional[str] = None
|
104 |
```
|
@@ -112,12 +110,20 @@ def chat_echo(prompt: str, messages: List[ChatMessage | ChatFileMessage]) -> Lis
|
|
112 |
return messages
|
113 |
```
|
114 |
|
115 |
-
### Why a different data format?
|
116 |
|
117 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
118 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
119 |
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
### Why are pydantic data classes required?
|
122 |
|
123 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
|
|
1 |
---
|
2 |
tags: [gradio-custom-component, Chatbot, chatbot, agents, streaming, tools]
|
3 |
title: gradio_agentchatbot
|
4 |
+
short_description: Chat with agents 🤖 and see their thoughts 💭
|
5 |
colorFrom: blue
|
6 |
colorTo: yellow
|
7 |
sdk: gradio
|
|
|
80 |
|
81 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
82 |
|
83 |
+
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how they are defined:
|
84 |
|
85 |
```python
|
86 |
class ThoughtMetadata(GradioModel):
|
|
|
91 |
class ChatMessage(GradioModel):
|
92 |
role: Literal["user", "assistant"]
|
93 |
content: str
|
|
|
94 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
95 |
|
96 |
|
97 |
class ChatFileMessage(GradioModel):
|
98 |
role: Literal["user", "assistant"]
|
99 |
file: FileData
|
|
|
100 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
101 |
alt_text: Optional[str] = None
|
102 |
```
|
|
|
110 |
return messages
|
111 |
```
|
112 |
|
113 |
+
### Why a different data format than Gradio core?
|
114 |
|
115 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
116 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
117 |
|
118 |
|
119 |
+
### What is `thought_metadata` field for?
|
120 |
+
|
121 |
+
You can use this to add additional information data about the current thought, like the names of the tool used.
|
122 |
+
If the `thought_metadata.tool_name` field is not `None`, the message `content` will be displayed in a collapsible tool modal. See below:
|
123 |
+
|
124 |
+
![Tool Modal](https://gradio-builds.s3.amazonaws.com/demo-files/tool_modal.gif)
|
125 |
+
|
126 |
+
|
127 |
### Why are pydantic data classes required?
|
128 |
|
129 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
app.py
CHANGED
@@ -37,6 +37,7 @@ def interact_with_agent(prompt, messages):
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Tabs():
|
39 |
with gr.Tab("Demo"):
|
|
|
40 |
chatbot = AgentChatbot(
|
41 |
label="Agent",
|
42 |
avatar_images=[
|
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Tabs():
|
39 |
with gr.Tab("Demo"):
|
40 |
+
gr.Markdown("# Chat with an LLM Agent 🤖 and see its thoughts 💭")
|
41 |
chatbot = AgentChatbot(
|
42 |
label="Agent",
|
43 |
avatar_images=[
|
docs.md
CHANGED
@@ -69,7 +69,7 @@ if __name__ == "__main__":
|
|
69 |
|
70 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
71 |
|
72 |
-
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how
|
73 |
|
74 |
```python
|
75 |
class ThoughtMetadata(GradioModel):
|
@@ -80,14 +80,12 @@ class ThoughtMetadata(GradioModel):
|
|
80 |
class ChatMessage(GradioModel):
|
81 |
role: Literal["user", "assistant"]
|
82 |
content: str
|
83 |
-
thought: bool = False
|
84 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
85 |
|
86 |
|
87 |
class ChatFileMessage(GradioModel):
|
88 |
role: Literal["user", "assistant"]
|
89 |
file: FileData
|
90 |
-
thought: bool = False
|
91 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
92 |
alt_text: Optional[str] = None
|
93 |
```
|
@@ -101,12 +99,20 @@ def chat_echo(prompt: str, messages: List[ChatMessage | ChatFileMessage]) -> Lis
|
|
101 |
return messages
|
102 |
```
|
103 |
|
104 |
-
### Why a different data format?
|
105 |
|
106 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
107 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
108 |
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
### Why are pydantic data classes required?
|
111 |
|
112 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
|
|
69 |
|
70 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
71 |
|
72 |
+
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how they are defined:
|
73 |
|
74 |
```python
|
75 |
class ThoughtMetadata(GradioModel):
|
|
|
80 |
class ChatMessage(GradioModel):
|
81 |
role: Literal["user", "assistant"]
|
82 |
content: str
|
|
|
83 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
84 |
|
85 |
|
86 |
class ChatFileMessage(GradioModel):
|
87 |
role: Literal["user", "assistant"]
|
88 |
file: FileData
|
|
|
89 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
90 |
alt_text: Optional[str] = None
|
91 |
```
|
|
|
99 |
return messages
|
100 |
```
|
101 |
|
102 |
+
### Why a different data format than Gradio core?
|
103 |
|
104 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
105 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
106 |
|
107 |
|
108 |
+
### What is `thought_metadata` field for?
|
109 |
+
|
110 |
+
You can use this to add additional information data about the current thought, like the names of the tool used.
|
111 |
+
If the `thought_metadata.tool_name` field is not `None`, the message `content` will be displayed in a collapsible tool modal. See below:
|
112 |
+
|
113 |
+
![Tool Modal](https://gradio-builds.s3.amazonaws.com/demo-files/tool_modal.gif)
|
114 |
+
|
115 |
+
|
116 |
### Why are pydantic data classes required?
|
117 |
|
118 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
gradio_agentchatbot
|
2 |
git+https://github.com/huggingface/transformers.git#egg=transformers[agents]
|
3 |
langchain
|
4 |
langchain-community
|
|
|
1 |
+
gradio_agentchatbot==0.0.2
|
2 |
git+https://github.com/huggingface/transformers.git#egg=transformers[agents]
|
3 |
langchain
|
4 |
langchain-community
|
src/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
src/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
tags: [gradio-custom-component, Chatbot, chatbot, agents, streaming, tools]
|
3 |
title: gradio_agentchatbot
|
4 |
-
short_description: Chat with agents and see
|
5 |
colorFrom: blue
|
6 |
colorTo: yellow
|
7 |
sdk: gradio
|
8 |
pinned: false
|
9 |
-
app_file:
|
10 |
---
|
11 |
|
12 |
# gradio_agentchatbot
|
@@ -80,7 +80,7 @@ if __name__ == "__main__":
|
|
80 |
|
81 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
82 |
|
83 |
-
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how
|
84 |
|
85 |
```python
|
86 |
class ThoughtMetadata(GradioModel):
|
@@ -91,14 +91,12 @@ class ThoughtMetadata(GradioModel):
|
|
91 |
class ChatMessage(GradioModel):
|
92 |
role: Literal["user", "assistant"]
|
93 |
content: str
|
94 |
-
thought: bool = False
|
95 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
96 |
|
97 |
|
98 |
class ChatFileMessage(GradioModel):
|
99 |
role: Literal["user", "assistant"]
|
100 |
file: FileData
|
101 |
-
thought: bool = False
|
102 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
103 |
alt_text: Optional[str] = None
|
104 |
```
|
@@ -112,12 +110,20 @@ def chat_echo(prompt: str, messages: List[ChatMessage | ChatFileMessage]) -> Lis
|
|
112 |
return messages
|
113 |
```
|
114 |
|
115 |
-
### Why a different data format?
|
116 |
|
117 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
118 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
119 |
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
### Why are pydantic data classes required?
|
122 |
|
123 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
|
|
1 |
---
|
2 |
tags: [gradio-custom-component, Chatbot, chatbot, agents, streaming, tools]
|
3 |
title: gradio_agentchatbot
|
4 |
+
short_description: Chat with agents 🤖 and see their thoughts 💭
|
5 |
colorFrom: blue
|
6 |
colorTo: yellow
|
7 |
sdk: gradio
|
8 |
pinned: false
|
9 |
+
app_file: app.py
|
10 |
---
|
11 |
|
12 |
# gradio_agentchatbot
|
|
|
80 |
|
81 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
82 |
|
83 |
+
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how they are defined:
|
84 |
|
85 |
```python
|
86 |
class ThoughtMetadata(GradioModel):
|
|
|
91 |
class ChatMessage(GradioModel):
|
92 |
role: Literal["user", "assistant"]
|
93 |
content: str
|
|
|
94 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
95 |
|
96 |
|
97 |
class ChatFileMessage(GradioModel):
|
98 |
role: Literal["user", "assistant"]
|
99 |
file: FileData
|
|
|
100 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
101 |
alt_text: Optional[str] = None
|
102 |
```
|
|
|
110 |
return messages
|
111 |
```
|
112 |
|
113 |
+
### Why a different data format than Gradio core?
|
114 |
|
115 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
116 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
117 |
|
118 |
|
119 |
+
### What is `thought_metadata` field for?
|
120 |
+
|
121 |
+
You can use this to add additional information data about the current thought, like the names of the tool used.
|
122 |
+
If the `thought_metadata.tool_name` field is not `None`, the message `content` will be displayed in a collapsible tool modal. See below:
|
123 |
+
|
124 |
+
![Tool Modal](https://gradio-builds.s3.amazonaws.com/demo-files/tool_modal.gif)
|
125 |
+
|
126 |
+
|
127 |
### Why are pydantic data classes required?
|
128 |
|
129 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
src/backend/gradio_agentchatbot/templates/component/index.js
CHANGED
@@ -2114,8 +2114,8 @@ function co() {
|
|
2114 |
} catch {
|
2115 |
}
|
2116 |
}
|
2117 |
-
const
|
2118 |
-
return z && ne &&
|
2119 |
}, X = function(z) {
|
2120 |
return O.call(
|
2121 |
z.ownerDocument || z,
|
@@ -2148,12 +2148,12 @@ function co() {
|
|
2148 |
if (!ie[ne] && w0(ne) && (be.tagNameCheck instanceof RegExp && ft(be.tagNameCheck, ne) || be.tagNameCheck instanceof Function && be.tagNameCheck(ne)))
|
2149 |
return !1;
|
2150 |
if (un && !S0[ne]) {
|
2151 |
-
const F = A(z) || z.parentNode,
|
2152 |
-
if (
|
2153 |
-
const Qe =
|
2154 |
for (let ot = Qe - 1; ot >= 0; --ot) {
|
2155 |
-
const
|
2156 |
-
|
2157 |
}
|
2158 |
}
|
2159 |
}
|
@@ -2209,40 +2209,40 @@ function co() {
|
|
2209 |
};
|
2210 |
let F = D.length;
|
2211 |
for (; F--; ) {
|
2212 |
-
const
|
2213 |
name: Qe,
|
2214 |
namespaceURI: ot,
|
2215 |
-
value:
|
2216 |
-
} =
|
2217 |
-
let
|
2218 |
-
if (ne.attrName = ue, ne.attrValue =
|
2219 |
continue;
|
2220 |
-
if (!bt && ft(/\/>/i,
|
2221 |
h(Qe, z);
|
2222 |
continue;
|
2223 |
}
|
2224 |
-
if (p0 && ft(/((--!?|])>)|<\/(style|title)/i,
|
2225 |
h(Qe, z);
|
2226 |
continue;
|
2227 |
}
|
2228 |
it && lr([ce, pe, ve], (dn) => {
|
2229 |
-
|
2230 |
});
|
2231 |
const P0 = je(z.nodeName);
|
2232 |
-
if (lt(P0, ue,
|
2233 |
-
if (O0 && (ue === "id" || ue === "name") && (h(Qe, z),
|
2234 |
switch (q.getAttributeType(P0, ue)) {
|
2235 |
case "TrustedHTML": {
|
2236 |
-
|
2237 |
break;
|
2238 |
}
|
2239 |
case "TrustedScriptURL": {
|
2240 |
-
|
2241 |
break;
|
2242 |
}
|
2243 |
}
|
2244 |
try {
|
2245 |
-
ot ? z.setAttributeNS(ot, Qe,
|
2246 |
} catch {
|
2247 |
}
|
2248 |
}
|
@@ -2260,7 +2260,7 @@ function co() {
|
|
2260 |
De("afterSanitizeShadowDOM", z, null);
|
2261 |
};
|
2262 |
return n.sanitize = function(re) {
|
2263 |
-
let z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, D = null, ne = null, F = null,
|
2264 |
if (Q = !re, Q && (re = "<!-->"), typeof re != "string" && !E(re))
|
2265 |
if (typeof re.toString == "function") {
|
2266 |
if (re = re.toString(), typeof re != "string")
|
@@ -2271,8 +2271,8 @@ function co() {
|
|
2271 |
return re;
|
2272 |
if (g0 || Lt(z), n.removed = [], typeof re == "string" && (b0 = !1), b0) {
|
2273 |
if (re.nodeName) {
|
2274 |
-
const
|
2275 |
-
if (!Fe[
|
2276 |
throw Dn("root node is forbidden and cannot be sanitized in-place");
|
2277 |
}
|
2278 |
} else if (re instanceof p)
|
@@ -2289,23 +2289,23 @@ function co() {
|
|
2289 |
for (; F = Qe.nextNode(); ) {
|
2290 |
if (te(F))
|
2291 |
continue;
|
2292 |
-
const
|
2293 |
-
F.nodeType === G0.element && (
|
2294 |
}
|
2295 |
if (b0)
|
2296 |
return re;
|
2297 |
if (vt) {
|
2298 |
if (K0)
|
2299 |
-
for (
|
2300 |
-
|
2301 |
else
|
2302 |
-
|
2303 |
-
return (he.shadowroot || he.shadowrootmode) && (
|
2304 |
}
|
2305 |
let ot = ct ? D.outerHTML : D.innerHTML;
|
2306 |
return ct && Fe["!doctype"] && D.ownerDocument && D.ownerDocument.doctype && D.ownerDocument.doctype.name && ft(uo, D.ownerDocument.doctype.name) && (ot = "<!DOCTYPE " + D.ownerDocument.doctype.name + `>
|
2307 |
-
` + ot), it && lr([ce, pe, ve], (
|
2308 |
-
ot = kn(ot,
|
2309 |
}), S && r0 ? S.createHTML(ot) : ot;
|
2310 |
}, n.setConfig = function() {
|
2311 |
let re = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
@@ -5922,7 +5922,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
5922 |
}
|
5923 |
const d = "math", X = "text", w = "main", E = "ams", De = "accent-token", te = "bin", lt = "close", w0 = "inner", oe = "mathord", Xe = "op-token", re = "open", z = "punct", D = "rel", ne = "spacing", F = "textord";
|
5924 |
h(d, w, D, "≡", "\\equiv", !0), h(d, w, D, "≺", "\\prec", !0), h(d, w, D, "≻", "\\succ", !0), h(d, w, D, "∼", "\\sim", !0), h(d, w, D, "⊥", "\\perp"), h(d, w, D, "⪯", "\\preceq", !0), h(d, w, D, "⪰", "\\succeq", !0), h(d, w, D, "≃", "\\simeq", !0), h(d, w, D, "∣", "\\mid", !0), h(d, w, D, "≪", "\\ll", !0), h(d, w, D, "≫", "\\gg", !0), h(d, w, D, "≍", "\\asymp", !0), h(d, w, D, "∥", "\\parallel"), h(d, w, D, "⋈", "\\bowtie", !0), h(d, w, D, "⌣", "\\smile", !0), h(d, w, D, "⊑", "\\sqsubseteq", !0), h(d, w, D, "⊒", "\\sqsupseteq", !0), h(d, w, D, "≐", "\\doteq", !0), h(d, w, D, "⌢", "\\frown", !0), h(d, w, D, "∋", "\\ni", !0), h(d, w, D, "∝", "\\propto", !0), h(d, w, D, "⊢", "\\vdash", !0), h(d, w, D, "⊣", "\\dashv", !0), h(d, w, D, "∋", "\\owns"), h(d, w, z, ".", "\\ldotp"), h(d, w, z, "⋅", "\\cdotp"), h(d, w, F, "#", "\\#"), h(X, w, F, "#", "\\#"), h(d, w, F, "&", "\\&"), h(X, w, F, "&", "\\&"), h(d, w, F, "ℵ", "\\aleph", !0), h(d, w, F, "∀", "\\forall", !0), h(d, w, F, "ℏ", "\\hbar", !0), h(d, w, F, "∃", "\\exists", !0), h(d, w, F, "∇", "\\nabla", !0), h(d, w, F, "♭", "\\flat", !0), h(d, w, F, "ℓ", "\\ell", !0), h(d, w, F, "♮", "\\natural", !0), h(d, w, F, "♣", "\\clubsuit", !0), h(d, w, F, "℘", "\\wp", !0), h(d, w, F, "♯", "\\sharp", !0), h(d, w, F, "♢", "\\diamondsuit", !0), h(d, w, F, "ℜ", "\\Re", !0), h(d, w, F, "♡", "\\heartsuit", !0), h(d, w, F, "ℑ", "\\Im", !0), h(d, w, F, "♠", "\\spadesuit", !0), h(d, w, F, "§", "\\S", !0), h(X, w, F, "§", "\\S"), h(d, w, F, "¶", "\\P", !0), h(X, w, F, "¶", "\\P"), h(d, w, F, "†", "\\dag"), h(X, w, F, "†", "\\dag"), h(X, w, F, "†", "\\textdagger"), h(d, w, F, "‡", "\\ddag"), h(X, w, F, "‡", "\\ddag"), h(X, w, F, "‡", "\\textdaggerdbl"), h(d, w, lt, "⎱", "\\rmoustache", !0), h(d, w, re, "⎰", "\\lmoustache", !0), h(d, w, lt, "⟯", "\\rgroup", !0), h(d, w, re, "⟮", "\\lgroup", !0), h(d, w, te, "∓", "\\mp", !0), h(d, w, te, "⊖", "\\ominus", !0), h(d, w, te, "⊎", "\\uplus", !0), h(d, w, te, "⊓", "\\sqcap", !0), h(d, w, te, "∗", "\\ast"), h(d, w, te, "⊔", "\\sqcup", !0), h(d, w, te, "◯", "\\bigcirc", !0), h(d, w, te, "∙", "\\bullet", !0), h(d, w, te, "‡", "\\ddagger"), h(d, w, te, "≀", "\\wr", !0), h(d, w, te, "⨿", "\\amalg"), h(d, w, te, "&", "\\And"), h(d, w, D, "⟵", "\\longleftarrow", !0), h(d, w, D, "⇐", "\\Leftarrow", !0), h(d, w, D, "⟸", "\\Longleftarrow", !0), h(d, w, D, "⟶", "\\longrightarrow", !0), h(d, w, D, "⇒", "\\Rightarrow", !0), h(d, w, D, "⟹", "\\Longrightarrow", !0), h(d, w, D, "↔", "\\leftrightarrow", !0), h(d, w, D, "⟷", "\\longleftrightarrow", !0), h(d, w, D, "⇔", "\\Leftrightarrow", !0), h(d, w, D, "⟺", "\\Longleftrightarrow", !0), h(d, w, D, "↦", "\\mapsto", !0), h(d, w, D, "⟼", "\\longmapsto", !0), h(d, w, D, "↗", "\\nearrow", !0), h(d, w, D, "↩", "\\hookleftarrow", !0), h(d, w, D, "↪", "\\hookrightarrow", !0), h(d, w, D, "↘", "\\searrow", !0), h(d, w, D, "↼", "\\leftharpoonup", !0), h(d, w, D, "⇀", "\\rightharpoonup", !0), h(d, w, D, "↙", "\\swarrow", !0), h(d, w, D, "↽", "\\leftharpoondown", !0), h(d, w, D, "⇁", "\\rightharpoondown", !0), h(d, w, D, "↖", "\\nwarrow", !0), h(d, w, D, "⇌", "\\rightleftharpoons", !0), h(d, E, D, "≮", "\\nless", !0), h(d, E, D, "", "\\@nleqslant"), h(d, E, D, "", "\\@nleqq"), h(d, E, D, "⪇", "\\lneq", !0), h(d, E, D, "≨", "\\lneqq", !0), h(d, E, D, "", "\\@lvertneqq"), h(d, E, D, "⋦", "\\lnsim", !0), h(d, E, D, "⪉", "\\lnapprox", !0), h(d, E, D, "⊀", "\\nprec", !0), h(d, E, D, "⋠", "\\npreceq", !0), h(d, E, D, "⋨", "\\precnsim", !0), h(d, E, D, "⪹", "\\precnapprox", !0), h(d, E, D, "≁", "\\nsim", !0), h(d, E, D, "", "\\@nshortmid"), h(d, E, D, "∤", "\\nmid", !0), h(d, E, D, "⊬", "\\nvdash", !0), h(d, E, D, "⊭", "\\nvDash", !0), h(d, E, D, "⋪", "\\ntriangleleft"), h(d, E, D, "⋬", "\\ntrianglelefteq", !0), h(d, E, D, "⊊", "\\subsetneq", !0), h(d, E, D, "", "\\@varsubsetneq"), h(d, E, D, "⫋", "\\subsetneqq", !0), h(d, E, D, "", "\\@varsubsetneqq"), h(d, E, D, "≯", "\\ngtr", !0), h(d, E, D, "", "\\@ngeqslant"), h(d, E, D, "", "\\@ngeqq"), h(d, E, D, "⪈", "\\gneq", !0), h(d, E, D, "≩", "\\gneqq", !0), h(d, E, D, "", "\\@gvertneqq"), h(d, E, D, "⋧", "\\gnsim", !0), h(d, E, D, "⪊", "\\gnapprox", !0), h(d, E, D, "⊁", "\\nsucc", !0), h(d, E, D, "⋡", "\\nsucceq", !0), h(d, E, D, "⋩", "\\succnsim", !0), h(d, E, D, "⪺", "\\succnapprox", !0), h(d, E, D, "≆", "\\ncong", !0), h(d, E, D, "", "\\@nshortparallel"), h(d, E, D, "∦", "\\nparallel", !0), h(d, E, D, "⊯", "\\nVDash", !0), h(d, E, D, "⋫", "\\ntriangleright"), h(d, E, D, "⋭", "\\ntrianglerighteq", !0), h(d, E, D, "", "\\@nsupseteqq"), h(d, E, D, "⊋", "\\supsetneq", !0), h(d, E, D, "", "\\@varsupsetneq"), h(d, E, D, "⫌", "\\supsetneqq", !0), h(d, E, D, "", "\\@varsupsetneqq"), h(d, E, D, "⊮", "\\nVdash", !0), h(d, E, D, "⪵", "\\precneqq", !0), h(d, E, D, "⪶", "\\succneqq", !0), h(d, E, D, "", "\\@nsubseteqq"), h(d, E, te, "⊴", "\\unlhd"), h(d, E, te, "⊵", "\\unrhd"), h(d, E, D, "↚", "\\nleftarrow", !0), h(d, E, D, "↛", "\\nrightarrow", !0), h(d, E, D, "⇍", "\\nLeftarrow", !0), h(d, E, D, "⇏", "\\nRightarrow", !0), h(d, E, D, "↮", "\\nleftrightarrow", !0), h(d, E, D, "⇎", "\\nLeftrightarrow", !0), h(d, E, D, "△", "\\vartriangle"), h(d, E, F, "ℏ", "\\hslash"), h(d, E, F, "▽", "\\triangledown"), h(d, E, F, "◊", "\\lozenge"), h(d, E, F, "Ⓢ", "\\circledS"), h(d, E, F, "®", "\\circledR"), h(X, E, F, "®", "\\circledR"), h(d, E, F, "∡", "\\measuredangle", !0), h(d, E, F, "∄", "\\nexists"), h(d, E, F, "℧", "\\mho"), h(d, E, F, "Ⅎ", "\\Finv", !0), h(d, E, F, "⅁", "\\Game", !0), h(d, E, F, "‵", "\\backprime"), h(d, E, F, "▲", "\\blacktriangle"), h(d, E, F, "▼", "\\blacktriangledown"), h(d, E, F, "■", "\\blacksquare"), h(d, E, F, "⧫", "\\blacklozenge"), h(d, E, F, "★", "\\bigstar"), h(d, E, F, "∢", "\\sphericalangle", !0), h(d, E, F, "∁", "\\complement", !0), h(d, E, F, "ð", "\\eth", !0), h(X, w, F, "ð", "ð"), h(d, E, F, "╱", "\\diagup"), h(d, E, F, "╲", "\\diagdown"), h(d, E, F, "□", "\\square"), h(d, E, F, "□", "\\Box"), h(d, E, F, "◊", "\\Diamond"), h(d, E, F, "¥", "\\yen", !0), h(X, E, F, "¥", "\\yen", !0), h(d, E, F, "✓", "\\checkmark", !0), h(X, E, F, "✓", "\\checkmark"), h(d, E, F, "ℶ", "\\beth", !0), h(d, E, F, "ℸ", "\\daleth", !0), h(d, E, F, "ℷ", "\\gimel", !0), h(d, E, F, "ϝ", "\\digamma", !0), h(d, E, F, "ϰ", "\\varkappa"), h(d, E, re, "┌", "\\@ulcorner", !0), h(d, E, lt, "┐", "\\@urcorner", !0), h(d, E, re, "└", "\\@llcorner", !0), h(d, E, lt, "┘", "\\@lrcorner", !0), h(d, E, D, "≦", "\\leqq", !0), h(d, E, D, "⩽", "\\leqslant", !0), h(d, E, D, "⪕", "\\eqslantless", !0), h(d, E, D, "≲", "\\lesssim", !0), h(d, E, D, "⪅", "\\lessapprox", !0), h(d, E, D, "≊", "\\approxeq", !0), h(d, E, te, "⋖", "\\lessdot"), h(d, E, D, "⋘", "\\lll", !0), h(d, E, D, "≶", "\\lessgtr", !0), h(d, E, D, "⋚", "\\lesseqgtr", !0), h(d, E, D, "⪋", "\\lesseqqgtr", !0), h(d, E, D, "≑", "\\doteqdot"), h(d, E, D, "≓", "\\risingdotseq", !0), h(d, E, D, "≒", "\\fallingdotseq", !0), h(d, E, D, "∽", "\\backsim", !0), h(d, E, D, "⋍", "\\backsimeq", !0), h(d, E, D, "⫅", "\\subseteqq", !0), h(d, E, D, "⋐", "\\Subset", !0), h(d, E, D, "⊏", "\\sqsubset", !0), h(d, E, D, "≼", "\\preccurlyeq", !0), h(d, E, D, "⋞", "\\curlyeqprec", !0), h(d, E, D, "≾", "\\precsim", !0), h(d, E, D, "⪷", "\\precapprox", !0), h(d, E, D, "⊲", "\\vartriangleleft"), h(d, E, D, "⊴", "\\trianglelefteq"), h(d, E, D, "⊨", "\\vDash", !0), h(d, E, D, "⊪", "\\Vvdash", !0), h(d, E, D, "⌣", "\\smallsmile"), h(d, E, D, "⌢", "\\smallfrown"), h(d, E, D, "≏", "\\bumpeq", !0), h(d, E, D, "≎", "\\Bumpeq", !0), h(d, E, D, "≧", "\\geqq", !0), h(d, E, D, "⩾", "\\geqslant", !0), h(d, E, D, "⪖", "\\eqslantgtr", !0), h(d, E, D, "≳", "\\gtrsim", !0), h(d, E, D, "⪆", "\\gtrapprox", !0), h(d, E, te, "⋗", "\\gtrdot"), h(d, E, D, "⋙", "\\ggg", !0), h(d, E, D, "≷", "\\gtrless", !0), h(d, E, D, "⋛", "\\gtreqless", !0), h(d, E, D, "⪌", "\\gtreqqless", !0), h(d, E, D, "≖", "\\eqcirc", !0), h(d, E, D, "≗", "\\circeq", !0), h(d, E, D, "≜", "\\triangleq", !0), h(d, E, D, "∼", "\\thicksim"), h(d, E, D, "≈", "\\thickapprox"), h(d, E, D, "⫆", "\\supseteqq", !0), h(d, E, D, "⋑", "\\Supset", !0), h(d, E, D, "⊐", "\\sqsupset", !0), h(d, E, D, "≽", "\\succcurlyeq", !0), h(d, E, D, "⋟", "\\curlyeqsucc", !0), h(d, E, D, "��", "\\succsim", !0), h(d, E, D, "⪸", "\\succapprox", !0), h(d, E, D, "⊳", "\\vartriangleright"), h(d, E, D, "⊵", "\\trianglerighteq"), h(d, E, D, "⊩", "\\Vdash", !0), h(d, E, D, "∣", "\\shortmid"), h(d, E, D, "∥", "\\shortparallel"), h(d, E, D, "≬", "\\between", !0), h(d, E, D, "⋔", "\\pitchfork", !0), h(d, E, D, "∝", "\\varpropto"), h(d, E, D, "◀", "\\blacktriangleleft"), h(d, E, D, "∴", "\\therefore", !0), h(d, E, D, "∍", "\\backepsilon"), h(d, E, D, "▶", "\\blacktriangleright"), h(d, E, D, "∵", "\\because", !0), h(d, E, D, "⋘", "\\llless"), h(d, E, D, "⋙", "\\gggtr"), h(d, E, te, "⊲", "\\lhd"), h(d, E, te, "⊳", "\\rhd"), h(d, E, D, "≂", "\\eqsim", !0), h(d, w, D, "⋈", "\\Join"), h(d, E, D, "≑", "\\Doteq", !0), h(d, E, te, "∔", "\\dotplus", !0), h(d, E, te, "∖", "\\smallsetminus"), h(d, E, te, "⋒", "\\Cap", !0), h(d, E, te, "⋓", "\\Cup", !0), h(d, E, te, "⩞", "\\doublebarwedge", !0), h(d, E, te, "⊟", "\\boxminus", !0), h(d, E, te, "⊞", "\\boxplus", !0), h(d, E, te, "⋇", "\\divideontimes", !0), h(d, E, te, "⋉", "\\ltimes", !0), h(d, E, te, "⋊", "\\rtimes", !0), h(d, E, te, "⋋", "\\leftthreetimes", !0), h(d, E, te, "⋌", "\\rightthreetimes", !0), h(d, E, te, "⋏", "\\curlywedge", !0), h(d, E, te, "⋎", "\\curlyvee", !0), h(d, E, te, "⊝", "\\circleddash", !0), h(d, E, te, "⊛", "\\circledast", !0), h(d, E, te, "⋅", "\\centerdot"), h(d, E, te, "⊺", "\\intercal", !0), h(d, E, te, "⋒", "\\doublecap"), h(d, E, te, "⋓", "\\doublecup"), h(d, E, te, "⊠", "\\boxtimes", !0), h(d, E, D, "⇢", "\\dashrightarrow", !0), h(d, E, D, "⇠", "\\dashleftarrow", !0), h(d, E, D, "⇇", "\\leftleftarrows", !0), h(d, E, D, "⇆", "\\leftrightarrows", !0), h(d, E, D, "⇚", "\\Lleftarrow", !0), h(d, E, D, "↞", "\\twoheadleftarrow", !0), h(d, E, D, "↢", "\\leftarrowtail", !0), h(d, E, D, "↫", "\\looparrowleft", !0), h(d, E, D, "⇋", "\\leftrightharpoons", !0), h(d, E, D, "↶", "\\curvearrowleft", !0), h(d, E, D, "↺", "\\circlearrowleft", !0), h(d, E, D, "↰", "\\Lsh", !0), h(d, E, D, "⇈", "\\upuparrows", !0), h(d, E, D, "↿", "\\upharpoonleft", !0), h(d, E, D, "⇃", "\\downharpoonleft", !0), h(d, w, D, "⊶", "\\origof", !0), h(d, w, D, "⊷", "\\imageof", !0), h(d, E, D, "⊸", "\\multimap", !0), h(d, E, D, "↭", "\\leftrightsquigarrow", !0), h(d, E, D, "⇉", "\\rightrightarrows", !0), h(d, E, D, "⇄", "\\rightleftarrows", !0), h(d, E, D, "↠", "\\twoheadrightarrow", !0), h(d, E, D, "↣", "\\rightarrowtail", !0), h(d, E, D, "↬", "\\looparrowright", !0), h(d, E, D, "↷", "\\curvearrowright", !0), h(d, E, D, "↻", "\\circlearrowright", !0), h(d, E, D, "↱", "\\Rsh", !0), h(d, E, D, "⇊", "\\downdownarrows", !0), h(d, E, D, "↾", "\\upharpoonright", !0), h(d, E, D, "⇂", "\\downharpoonright", !0), h(d, E, D, "⇝", "\\rightsquigarrow", !0), h(d, E, D, "⇝", "\\leadsto"), h(d, E, D, "⇛", "\\Rrightarrow", !0), h(d, E, D, "↾", "\\restriction"), h(d, w, F, "‘", "`"), h(d, w, F, "$", "\\$"), h(X, w, F, "$", "\\$"), h(X, w, F, "$", "\\textdollar"), h(d, w, F, "%", "\\%"), h(X, w, F, "%", "\\%"), h(d, w, F, "_", "\\_"), h(X, w, F, "_", "\\_"), h(X, w, F, "_", "\\textunderscore"), h(d, w, F, "∠", "\\angle", !0), h(d, w, F, "∞", "\\infty", !0), h(d, w, F, "′", "\\prime"), h(d, w, F, "△", "\\triangle"), h(d, w, F, "Γ", "\\Gamma", !0), h(d, w, F, "Δ", "\\Delta", !0), h(d, w, F, "Θ", "\\Theta", !0), h(d, w, F, "Λ", "\\Lambda", !0), h(d, w, F, "Ξ", "\\Xi", !0), h(d, w, F, "Π", "\\Pi", !0), h(d, w, F, "Σ", "\\Sigma", !0), h(d, w, F, "Υ", "\\Upsilon", !0), h(d, w, F, "Φ", "\\Phi", !0), h(d, w, F, "Ψ", "\\Psi", !0), h(d, w, F, "Ω", "\\Omega", !0), h(d, w, F, "A", "Α"), h(d, w, F, "B", "Β"), h(d, w, F, "E", "Ε"), h(d, w, F, "Z", "Ζ"), h(d, w, F, "H", "Η"), h(d, w, F, "I", "Ι"), h(d, w, F, "K", "Κ"), h(d, w, F, "M", "Μ"), h(d, w, F, "N", "Ν"), h(d, w, F, "O", "Ο"), h(d, w, F, "P", "Ρ"), h(d, w, F, "T", "Τ"), h(d, w, F, "X", "Χ"), h(d, w, F, "¬", "\\neg", !0), h(d, w, F, "¬", "\\lnot"), h(d, w, F, "⊤", "\\top"), h(d, w, F, "⊥", "\\bot"), h(d, w, F, "∅", "\\emptyset"), h(d, E, F, "∅", "\\varnothing"), h(d, w, oe, "α", "\\alpha", !0), h(d, w, oe, "β", "\\beta", !0), h(d, w, oe, "γ", "\\gamma", !0), h(d, w, oe, "δ", "\\delta", !0), h(d, w, oe, "ϵ", "\\epsilon", !0), h(d, w, oe, "ζ", "\\zeta", !0), h(d, w, oe, "η", "\\eta", !0), h(d, w, oe, "θ", "\\theta", !0), h(d, w, oe, "ι", "\\iota", !0), h(d, w, oe, "κ", "\\kappa", !0), h(d, w, oe, "λ", "\\lambda", !0), h(d, w, oe, "μ", "\\mu", !0), h(d, w, oe, "ν", "\\nu", !0), h(d, w, oe, "ξ", "\\xi", !0), h(d, w, oe, "ο", "\\omicron", !0), h(d, w, oe, "π", "\\pi", !0), h(d, w, oe, "ρ", "\\rho", !0), h(d, w, oe, "σ", "\\sigma", !0), h(d, w, oe, "τ", "\\tau", !0), h(d, w, oe, "υ", "\\upsilon", !0), h(d, w, oe, "ϕ", "\\phi", !0), h(d, w, oe, "χ", "\\chi", !0), h(d, w, oe, "ψ", "\\psi", !0), h(d, w, oe, "ω", "\\omega", !0), h(d, w, oe, "ε", "\\varepsilon", !0), h(d, w, oe, "ϑ", "\\vartheta", !0), h(d, w, oe, "ϖ", "\\varpi", !0), h(d, w, oe, "ϱ", "\\varrho", !0), h(d, w, oe, "ς", "\\varsigma", !0), h(d, w, oe, "φ", "\\varphi", !0), h(d, w, te, "∗", "*", !0), h(d, w, te, "+", "+"), h(d, w, te, "−", "-", !0), h(d, w, te, "⋅", "\\cdot", !0), h(d, w, te, "∘", "\\circ", !0), h(d, w, te, "÷", "\\div", !0), h(d, w, te, "±", "\\pm", !0), h(d, w, te, "×", "\\times", !0), h(d, w, te, "∩", "\\cap", !0), h(d, w, te, "∪", "\\cup", !0), h(d, w, te, "∖", "\\setminus", !0), h(d, w, te, "∧", "\\land"), h(d, w, te, "∨", "\\lor"), h(d, w, te, "∧", "\\wedge", !0), h(d, w, te, "∨", "\\vee", !0), h(d, w, F, "√", "\\surd"), h(d, w, re, "⟨", "\\langle", !0), h(d, w, re, "∣", "\\lvert"), h(d, w, re, "∥", "\\lVert"), h(d, w, lt, "?", "?"), h(d, w, lt, "!", "!"), h(d, w, lt, "⟩", "\\rangle", !0), h(d, w, lt, "∣", "\\rvert"), h(d, w, lt, "∥", "\\rVert"), h(d, w, D, "=", "="), h(d, w, D, ":", ":"), h(d, w, D, "≈", "\\approx", !0), h(d, w, D, "≅", "\\cong", !0), h(d, w, D, "≥", "\\ge"), h(d, w, D, "≥", "\\geq", !0), h(d, w, D, "←", "\\gets"), h(d, w, D, ">", "\\gt", !0), h(d, w, D, "∈", "\\in", !0), h(d, w, D, "", "\\@not"), h(d, w, D, "⊂", "\\subset", !0), h(d, w, D, "⊃", "\\supset", !0), h(d, w, D, "⊆", "\\subseteq", !0), h(d, w, D, "⊇", "\\supseteq", !0), h(d, E, D, "⊈", "\\nsubseteq", !0), h(d, E, D, "⊉", "\\nsupseteq", !0), h(d, w, D, "⊨", "\\models"), h(d, w, D, "←", "\\leftarrow", !0), h(d, w, D, "≤", "\\le"), h(d, w, D, "≤", "\\leq", !0), h(d, w, D, "<", "\\lt", !0), h(d, w, D, "→", "\\rightarrow", !0), h(d, w, D, "→", "\\to"), h(d, E, D, "≱", "\\ngeq", !0), h(d, E, D, "≰", "\\nleq", !0), h(d, w, ne, " ", "\\ "), h(d, w, ne, " ", "\\space"), h(d, w, ne, " ", "\\nobreakspace"), h(X, w, ne, " ", "\\ "), h(X, w, ne, " ", " "), h(X, w, ne, " ", "\\space"), h(X, w, ne, " ", "\\nobreakspace"), h(d, w, ne, null, "\\nobreak"), h(d, w, ne, null, "\\allowbreak"), h(d, w, z, ",", ","), h(d, w, z, ";", ";"), h(d, E, te, "⊼", "\\barwedge", !0), h(d, E, te, "⊻", "\\veebar", !0), h(d, w, te, "⊙", "\\odot", !0), h(d, w, te, "⊕", "\\oplus", !0), h(d, w, te, "⊗", "\\otimes", !0), h(d, w, F, "∂", "\\partial", !0), h(d, w, te, "⊘", "\\oslash", !0), h(d, E, te, "⊚", "\\circledcirc", !0), h(d, E, te, "⊡", "\\boxdot", !0), h(d, w, te, "△", "\\bigtriangleup"), h(d, w, te, "▽", "\\bigtriangledown"), h(d, w, te, "†", "\\dagger"), h(d, w, te, "⋄", "\\diamond"), h(d, w, te, "⋆", "\\star"), h(d, w, te, "◃", "\\triangleleft"), h(d, w, te, "▹", "\\triangleright"), h(d, w, re, "{", "\\{"), h(X, w, F, "{", "\\{"), h(X, w, F, "{", "\\textbraceleft"), h(d, w, lt, "}", "\\}"), h(X, w, F, "}", "\\}"), h(X, w, F, "}", "\\textbraceright"), h(d, w, re, "{", "\\lbrace"), h(d, w, lt, "}", "\\rbrace"), h(d, w, re, "[", "\\lbrack", !0), h(X, w, F, "[", "\\lbrack", !0), h(d, w, lt, "]", "\\rbrack", !0), h(X, w, F, "]", "\\rbrack", !0), h(d, w, re, "(", "\\lparen", !0), h(d, w, lt, ")", "\\rparen", !0), h(X, w, F, "<", "\\textless", !0), h(X, w, F, ">", "\\textgreater", !0), h(d, w, re, "⌊", "\\lfloor", !0), h(d, w, lt, "⌋", "\\rfloor", !0), h(d, w, re, "⌈", "\\lceil", !0), h(d, w, lt, "⌉", "\\rceil", !0), h(d, w, F, "\\", "\\backslash"), h(d, w, F, "∣", "|"), h(d, w, F, "∣", "\\vert"), h(X, w, F, "|", "\\textbar", !0), h(d, w, F, "∥", "\\|"), h(d, w, F, "∥", "\\Vert"), h(X, w, F, "∥", "\\textbardbl"), h(X, w, F, "~", "\\textasciitilde"), h(X, w, F, "\\", "\\textbackslash"), h(X, w, F, "^", "\\textasciicircum"), h(d, w, D, "↑", "\\uparrow", !0), h(d, w, D, "⇑", "\\Uparrow", !0), h(d, w, D, "↓", "\\downarrow", !0), h(d, w, D, "⇓", "\\Downarrow", !0), h(d, w, D, "↕", "\\updownarrow", !0), h(d, w, D, "⇕", "\\Updownarrow", !0), h(d, w, Xe, "∐", "\\coprod"), h(d, w, Xe, "⋁", "\\bigvee"), h(d, w, Xe, "⋀", "\\bigwedge"), h(d, w, Xe, "⨄", "\\biguplus"), h(d, w, Xe, "⋂", "\\bigcap"), h(d, w, Xe, "⋃", "\\bigcup"), h(d, w, Xe, "∫", "\\int"), h(d, w, Xe, "∫", "\\intop"), h(d, w, Xe, "∬", "\\iint"), h(d, w, Xe, "∭", "\\iiint"), h(d, w, Xe, "∏", "\\prod"), h(d, w, Xe, "∑", "\\sum"), h(d, w, Xe, "⨂", "\\bigotimes"), h(d, w, Xe, "⨁", "\\bigoplus"), h(d, w, Xe, "⨀", "\\bigodot"), h(d, w, Xe, "∮", "\\oint"), h(d, w, Xe, "∯", "\\oiint"), h(d, w, Xe, "∰", "\\oiiint"), h(d, w, Xe, "⨆", "\\bigsqcup"), h(d, w, Xe, "∫", "\\smallint"), h(X, w, w0, "…", "\\textellipsis"), h(d, w, w0, "…", "\\mathellipsis"), h(X, w, w0, "…", "\\ldots", !0), h(d, w, w0, "…", "\\ldots", !0), h(d, w, w0, "⋯", "\\@cdots", !0), h(d, w, w0, "⋱", "\\ddots", !0), h(d, w, F, "⋮", "\\varvdots"), h(d, w, De, "ˊ", "\\acute"), h(d, w, De, "ˋ", "\\grave"), h(d, w, De, "¨", "\\ddot"), h(d, w, De, "~", "\\tilde"), h(d, w, De, "ˉ", "\\bar"), h(d, w, De, "˘", "\\breve"), h(d, w, De, "ˇ", "\\check"), h(d, w, De, "^", "\\hat"), h(d, w, De, "⃗", "\\vec"), h(d, w, De, "˙", "\\dot"), h(d, w, De, "˚", "\\mathring"), h(d, w, oe, "", "\\@imath"), h(d, w, oe, "", "\\@jmath"), h(d, w, F, "ı", "ı"), h(d, w, F, "ȷ", "ȷ"), h(X, w, F, "ı", "\\i", !0), h(X, w, F, "ȷ", "\\j", !0), h(X, w, F, "ß", "\\ss", !0), h(X, w, F, "æ", "\\ae", !0), h(X, w, F, "œ", "\\oe", !0), h(X, w, F, "ø", "\\o", !0), h(X, w, F, "Æ", "\\AE", !0), h(X, w, F, "Œ", "\\OE", !0), h(X, w, F, "Ø", "\\O", !0), h(X, w, De, "ˊ", "\\'"), h(X, w, De, "ˋ", "\\`"), h(X, w, De, "ˆ", "\\^"), h(X, w, De, "˜", "\\~"), h(X, w, De, "ˉ", "\\="), h(X, w, De, "˘", "\\u"), h(X, w, De, "˙", "\\."), h(X, w, De, "¸", "\\c"), h(X, w, De, "˚", "\\r"), h(X, w, De, "ˇ", "\\v"), h(X, w, De, "¨", '\\"'), h(X, w, De, "˝", "\\H"), h(X, w, De, "◯", "\\textcircled");
|
5925 |
-
const
|
5926 |
"--": !0,
|
5927 |
"---": !0,
|
5928 |
"``": !0,
|
@@ -5939,15 +5939,15 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
5939 |
const e = ot.charAt(t);
|
5940 |
h(X, w, F, e, e);
|
5941 |
}
|
5942 |
-
const
|
5943 |
-
for (let t = 0; t <
|
5944 |
-
const e =
|
5945 |
h(d, w, oe, e, e), h(X, w, F, e, e);
|
5946 |
}
|
5947 |
h(d, E, F, "C", "ℂ"), h(X, E, F, "C", "ℂ"), h(d, E, F, "H", "ℍ"), h(X, E, F, "H", "ℍ"), h(d, E, F, "N", "ℕ"), h(X, E, F, "N", "ℕ"), h(d, E, F, "P", "ℙ"), h(X, E, F, "P", "ℙ"), h(d, E, F, "Q", "ℚ"), h(X, E, F, "Q", "ℚ"), h(d, E, F, "R", "ℝ"), h(X, E, F, "R", "ℝ"), h(d, E, F, "Z", "ℤ"), h(X, E, F, "Z", "ℤ"), h(d, w, oe, "h", "ℎ"), h(X, w, oe, "h", "ℎ");
|
5948 |
let ue = "";
|
5949 |
-
for (let t = 0; t <
|
5950 |
-
const e =
|
5951 |
ue = String.fromCharCode(55349, 56320 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56372 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56424 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56580 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56684 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56736 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56788 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56840 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56944 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), t < 26 && (ue = String.fromCharCode(55349, 56632 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56476 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue));
|
5952 |
}
|
5953 |
ue = "𝕜", h(d, w, oe, "k", ue), h(X, w, F, "k", ue);
|
@@ -5955,9 +5955,9 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
5955 |
const e = t.toString();
|
5956 |
ue = String.fromCharCode(55349, 57294 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57314 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57324 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57334 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue);
|
5957 |
}
|
5958 |
-
const
|
5959 |
-
for (let t = 0; t <
|
5960 |
-
const e =
|
5961 |
h(d, w, oe, e, e), h(X, w, F, e, e);
|
5962 |
}
|
5963 |
const P0 = [
|
@@ -6086,7 +6086,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
6086 |
g ? (N = ai[_].fontName, R = [_]) : (N = Gn(_, e.fontWeight, e.fontShape), R = [_, e.fontWeight, e.fontShape]);
|
6087 |
if (Un(c, N, l).metrics)
|
6088 |
return Zt(c, N, l, e, m.concat(R));
|
6089 |
-
if (
|
6090 |
const P = [];
|
6091 |
for (let Y = 0; Y < c.length; Y++)
|
6092 |
P.push(Zt(c[Y], N, l, e, m.concat(R)));
|
@@ -6482,7 +6482,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
6482 |
mclose: "mclose",
|
6483 |
mpunct: "mpunct",
|
6484 |
minner: "minner"
|
6485 |
-
},
|
6486 |
l === void 0 && (l = [null, null]);
|
6487 |
const c = [];
|
6488 |
for (let T = 0; T < t.length; T++) {
|
@@ -6572,7 +6572,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
6572 |
function qr(t, e) {
|
6573 |
let r = null;
|
6574 |
t.length === 1 && t[0].type === "tag" && (r = t[0].tag, t = t[0].body);
|
6575 |
-
const l =
|
6576 |
let c;
|
6577 |
l.length === 2 && l[1].hasClass("tag") && (c = l.pop());
|
6578 |
const m = [];
|
@@ -6587,7 +6587,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
6587 |
l[T].hasClass("newline") && (g.pop(), g.length > 0 && (m.push(Xn(g, e)), g = []), m.push(l[T]));
|
6588 |
g.length > 0 && m.push(Xn(g, e));
|
6589 |
let _;
|
6590 |
-
r ? (_ = Xn(
|
6591 |
const v = _0(["katex-html"], m);
|
6592 |
if (v.setAttribute("aria-hidden", "true"), _) {
|
6593 |
const T = _.children[0];
|
@@ -6709,7 +6709,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
6709 |
newDocumentFragment: hi
|
6710 |
};
|
6711 |
const qt = function(t, e, r) {
|
6712 |
-
return ye[e][t] && ye[e][t].replace && t.charCodeAt(0) !== 55349 && !(
|
6713 |
}, Pr = function(t) {
|
6714 |
return t.length === 1 ? t[0] : new Z.MathNode("mrow", t);
|
6715 |
}, Hr = function(t, e) {
|
@@ -7303,7 +7303,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
7303 |
});
|
7304 |
const wu = L.makeSpan;
|
7305 |
function gi(t, e) {
|
7306 |
-
const r =
|
7307 |
return wu([t.mclass], r, e);
|
7308 |
}
|
7309 |
function bi(t, e) {
|
@@ -7417,7 +7417,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
7417 |
};
|
7418 |
},
|
7419 |
htmlBuilder(t, e) {
|
7420 |
-
const r =
|
7421 |
return l.style.textShadow = "0.02em 0.01em 0.04px", l;
|
7422 |
},
|
7423 |
mathmlBuilder(t, e) {
|
@@ -7638,7 +7638,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
7638 |
}
|
7639 |
});
|
7640 |
const _i = (t, e) => {
|
7641 |
-
const r =
|
7642 |
return L.makeFragment(r);
|
7643 |
}, ki = (t, e) => {
|
7644 |
const r = _t(t.body, e.withColor(t.color)), l = new Z.MathNode("mstyle", r);
|
@@ -7919,7 +7919,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
7919 |
const Ye = gn(_, P, c);
|
7920 |
Te = Ye.height + Ye.depth, qe = 2;
|
7921 |
}
|
7922 |
-
const ht = se + xe + Te,
|
7923 |
let tn = l.fontMetrics().axisHeight;
|
7924 |
r && (tn *= l.sizeMultiplier);
|
7925 |
const Se = Ht / 2 - tn, ze = [];
|
@@ -8229,7 +8229,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8229 |
},
|
8230 |
htmlBuilder: (t, e) => {
|
8231 |
Bi(t);
|
8232 |
-
const r =
|
8233 |
let l = 0, c = 0, m = !1;
|
8234 |
for (let v = 0; v < r.length; v++)
|
8235 |
r[v].isMiddle ? m = !0 : (l = Math.max(r[v].height, l), c = Math.max(r[v].depth, c));
|
@@ -8649,8 +8649,8 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8649 |
break;
|
8650 |
} else if (ht === "\\\\") {
|
8651 |
t.consume();
|
8652 |
-
let
|
8653 |
-
t.gullet.future().text !== " " && (
|
8654 |
} else
|
8655 |
throw new o("Expected & or \\\\ or \\cr or \\end", t.nextToken);
|
8656 |
}
|
@@ -8710,13 +8710,13 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8710 |
Ye && (Ve = Ce(Ye, e), Ve > 0 && (Ve += ke, Pe < Ve && (Pe = Ve), Ve = 0)), t.addJot && (Pe += Y), Ue.height = ze, Ue.depth = Pe, ge += ze, Ue.pos = ge, ge += Pe + Ve, _[r] = Ue, xe(m[r + 1]);
|
8711 |
}
|
8712 |
const Te = ge / 2 + e.fontMetrics().axisHeight, qe = t.cols || [], ht = [];
|
8713 |
-
let
|
8714 |
const tn = [];
|
8715 |
if (t.tags && t.tags.some((Se) => Se))
|
8716 |
for (r = 0; r < c; ++r) {
|
8717 |
const Se = _[r], ze = Se.pos - Te, Pe = t.tags[r];
|
8718 |
let Ue;
|
8719 |
-
Pe === !0 ? Ue = L.makeSpan(["eqn-num"], [], e) : Pe === !1 ? Ue = L.makeSpan([], [], e) : Ue = L.makeSpan([],
|
8720 |
type: "elem",
|
8721 |
elem: Ue,
|
8722 |
shift: ze
|
@@ -8731,7 +8731,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8731 |
) {
|
8732 |
let Se = qe[Ht] || {}, ze = !0;
|
8733 |
for (; Se.type === "separator"; ) {
|
8734 |
-
if (ze || (
|
8735 |
const Ye = Se.separator === "|" ? "solid" : "dashed", Ve = L.makeSpan(["vertical-separator"], [], e);
|
8736 |
Ve.style.height = Q(ge), Ve.style.borderRightWidth = Q(T), Ve.style.borderRightStyle = Ye, Ve.style.margin = "0 " + Q(-T / 2);
|
8737 |
const Ut = ge - Te;
|
@@ -8743,7 +8743,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8743 |
if (l >= g)
|
8744 |
continue;
|
8745 |
let Pe;
|
8746 |
-
(l > 0 || t.hskipBeforeAndAfter) && (Pe = U.deflt(Se.pregap, R), Pe !== 0 && (
|
8747 |
let Ue = [];
|
8748 |
for (r = 0; r < c; ++r) {
|
8749 |
const Ye = _[r], Ve = Ye[l];
|
@@ -8759,7 +8759,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
8759 |
Ue = L.makeVList({
|
8760 |
positionType: "individualShift",
|
8761 |
children: Ue
|
8762 |
-
}, e), Ue = L.makeSpan(["col-align-" + (Se.align || "c")], [Ue]), ht.push(Ue), (l < g - 1 || t.hskipBeforeAndAfter) && (Pe = U.deflt(Se.postgap, R), Pe !== 0 && (
|
8763 |
}
|
8764 |
if (_ = L.makeSpan(["mtable"], ht), v.length > 0) {
|
8765 |
const Se = L.makeLineSpan("hline", e, T), ze = L.makeLineSpan("hdashline", e, T), Pe = [{
|
@@ -9709,7 +9709,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
9709 |
} : r.formatUnsupportedCmd("\\href");
|
9710 |
},
|
9711 |
htmlBuilder: (t, e) => {
|
9712 |
-
const r =
|
9713 |
return L.makeAnchor(t.href, [], r, e);
|
9714 |
},
|
9715 |
mathmlBuilder: (t, e) => {
|
@@ -9776,7 +9776,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
9776 |
};
|
9777 |
},
|
9778 |
htmlBuilder(t, e) {
|
9779 |
-
const r =
|
9780 |
return L.makeFragment(r);
|
9781 |
},
|
9782 |
mathmlBuilder(t, e) {
|
@@ -9844,7 +9844,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
9844 |
} : r.formatUnsupportedCmd(l);
|
9845 |
},
|
9846 |
htmlBuilder: (t, e) => {
|
9847 |
-
const r =
|
9848 |
t.attributes.class && l.push(...t.attributes.class.trim().split(/\s+/));
|
9849 |
const c = L.makeSpan(l, r, e);
|
9850 |
for (const m in t.attributes)
|
@@ -9871,7 +9871,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
9871 |
};
|
9872 |
},
|
9873 |
htmlBuilder: (t, e) => {
|
9874 |
-
const r =
|
9875 |
return L.makeFragment(r);
|
9876 |
},
|
9877 |
mathmlBuilder: (t, e) => C0(t.mathml, e)
|
@@ -10120,7 +10120,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10120 |
};
|
10121 |
},
|
10122 |
htmlBuilder: (t, e) => {
|
10123 |
-
const r = ji(t, e), l =
|
10124 |
return L.makeFragment(l);
|
10125 |
},
|
10126 |
mathmlBuilder: (t, e) => {
|
@@ -10251,7 +10251,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10251 |
}, e), m.name = "\\" + P, v.classes.unshift("mop"), v.italic = Y;
|
10252 |
}
|
10253 |
} else if (m.body) {
|
10254 |
-
const R =
|
10255 |
R.length === 1 && R[0] instanceof wt ? (v = R[0], v.classes[0] = "mop") : v = L.makeSpan(["mop"], R, e);
|
10256 |
} else {
|
10257 |
const R = [];
|
@@ -10420,7 +10420,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10420 |
mode: T.mode,
|
10421 |
text: N
|
10422 |
} : T;
|
10423 |
-
}), v =
|
10424 |
for (let T = 0; T < v.length; T++) {
|
10425 |
const N = v[T];
|
10426 |
N instanceof wt && (N.text = N.text.replace(/\u2212/, "-").replace(/\u2217/, "*"));
|
@@ -10488,7 +10488,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10488 |
}), k("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"), U0({
|
10489 |
type: "ordgroup",
|
10490 |
htmlBuilder(t, e) {
|
10491 |
-
return t.semisimple ? L.makeFragment(
|
10492 |
},
|
10493 |
mathmlBuilder(t, e) {
|
10494 |
return C0(t.body, e, !0);
|
@@ -10554,7 +10554,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10554 |
};
|
10555 |
},
|
10556 |
htmlBuilder: (t, e) => {
|
10557 |
-
const r =
|
10558 |
return L.makeFragment(r);
|
10559 |
},
|
10560 |
mathmlBuilder: (t, e) => {
|
@@ -10706,7 +10706,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10706 |
}
|
10707 |
});
|
10708 |
function Ki(t, e, r) {
|
10709 |
-
const l =
|
10710 |
for (let m = 0; m < l.length; m++) {
|
10711 |
const g = l[m].classes.indexOf("sizing");
|
10712 |
g < 0 ? Array.prototype.push.apply(l[m].classes, e.sizingClasses(r)) : l[m].classes[g + 1] === "reset-size" + e.size && (l[m].classes[g + 1] = "reset-size" + r.size), l[m].height *= c, l[m].depth *= c;
|
@@ -10959,8 +10959,8 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
10959 |
const qe = 4 * T.defaultRuleThickness;
|
10960 |
if (N - _.depth - (v.height - R) < qe) {
|
10961 |
R = qe - (N - _.depth) + v.height;
|
10962 |
-
const
|
10963 |
-
|
10964 |
}
|
10965 |
const ht = [{
|
10966 |
type: "elem",
|
@@ -11173,7 +11173,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
11173 |
};
|
11174 |
},
|
11175 |
htmlBuilder(t, e) {
|
11176 |
-
const r = rl(t, e), l =
|
11177 |
return L.makeSpan(["mord", "text"], l, r);
|
11178 |
},
|
11179 |
mathmlBuilder(t, e) {
|
@@ -12977,7 +12977,7 @@ l0,-` + (e + 144) + `c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
12977 |
l && (r = r.substring(0, l.index), r === "i" ? r = "ı" : r === "j" && (r = "ȷ"));
|
12978 |
let c;
|
12979 |
if (ye[this.mode][r]) {
|
12980 |
-
this.settings.strict && this.mode === "math" &&
|
12981 |
const m = ye[this.mode][r].group, g = Et.range(e);
|
12982 |
let _;
|
12983 |
if (Pn.hasOwnProperty(m)) {
|
@@ -18269,7 +18269,7 @@ const {
|
|
18269 |
set_style: An,
|
18270 |
space: si,
|
18271 |
text: Vf,
|
18272 |
-
toggle_class:
|
18273 |
transition_in: _e,
|
18274 |
transition_out: Me
|
18275 |
} = window.__gradio__svelte__internal, { beforeUpdate: Wf, afterUpdate: jf, createEventDispatcher: Xf } = window.__gradio__svelte__internal;
|
@@ -18498,14 +18498,14 @@ function Ua(a) {
|
|
18498 |
W[A].c();
|
18499 |
Be(u, "data-testid", o = /*role*/
|
18500 |
a[39]), Be(u, "dir", f = /*rtl*/
|
18501 |
-
a[5] ? "rtl" : "ltr"), Be(u, "class", "svelte-kqrm1b"),
|
18502 |
u,
|
18503 |
"latest",
|
18504 |
/*i*/
|
18505 |
a[38] === /*groupedMessages*/
|
18506 |
a[35].length - 1
|
18507 |
-
),
|
18508 |
-
a[9]),
|
18509 |
u,
|
18510 |
"selectable",
|
18511 |
/*selectable*/
|
@@ -18516,23 +18516,23 @@ function Ua(a) {
|
|
18516 |
/*rtl*/
|
18517 |
a[5] ? "right" : "left"
|
18518 |
), Be(i, "class", p = "message " + /*role*/
|
18519 |
-
(a[39] === "user" ? "user" : "bot") + " svelte-kqrm1b"),
|
18520 |
i,
|
18521 |
"message-fit",
|
18522 |
/*layout*/
|
18523 |
a[12] === "bubble" && !/*bubble_full_width*/
|
18524 |
a[8]
|
18525 |
-
),
|
18526 |
i,
|
18527 |
"panel-full-width",
|
18528 |
/*layout*/
|
18529 |
a[12] === "panel"
|
18530 |
-
),
|
18531 |
i,
|
18532 |
"message-bubble-border",
|
18533 |
/*layout*/
|
18534 |
a[12] === "bubble"
|
18535 |
-
),
|
18536 |
a[9]), An(
|
18537 |
i,
|
18538 |
"text-align",
|
@@ -18577,16 +18577,16 @@ function Ua(a) {
|
|
18577 |
a[39])) && Be(u, "data-testid", o), (!y || S[0] & /*rtl*/
|
18578 |
32 && f !== (f = /*rtl*/
|
18579 |
a[5] ? "rtl" : "ltr")) && Be(u, "dir", f), (!y || S[0] & /*value*/
|
18580 |
-
1) &&
|
18581 |
u,
|
18582 |
"latest",
|
18583 |
/*i*/
|
18584 |
a[38] === /*groupedMessages*/
|
18585 |
a[35].length - 1
|
18586 |
), (!y || S[0] & /*render_markdown*/
|
18587 |
-
512) &&
|
18588 |
a[9]), (!y || S[0] & /*selectable*/
|
18589 |
-
8) &&
|
18590 |
u,
|
18591 |
"selectable",
|
18592 |
/*selectable*/
|
@@ -18600,26 +18600,26 @@ function Ua(a) {
|
|
18600 |
), (!y || S[0] & /*value*/
|
18601 |
1 && p !== (p = "message " + /*role*/
|
18602 |
(a[39] === "user" ? "user" : "bot") + " svelte-kqrm1b")) && Be(i, "class", p), (!y || S[0] & /*value, layout, bubble_full_width*/
|
18603 |
-
4353) &&
|
18604 |
i,
|
18605 |
"message-fit",
|
18606 |
/*layout*/
|
18607 |
a[12] === "bubble" && !/*bubble_full_width*/
|
18608 |
a[8]
|
18609 |
), (!y || S[0] & /*value, layout*/
|
18610 |
-
4097) &&
|
18611 |
i,
|
18612 |
"panel-full-width",
|
18613 |
/*layout*/
|
18614 |
a[12] === "panel"
|
18615 |
), (!y || S[0] & /*value, layout*/
|
18616 |
-
4097) &&
|
18617 |
i,
|
18618 |
"message-bubble-border",
|
18619 |
/*layout*/
|
18620 |
a[12] === "bubble"
|
18621 |
), (!y || S[0] & /*value, render_markdown*/
|
18622 |
-
513) &&
|
18623 |
a[9]), S[0] & /*rtl, value*/
|
18624 |
33 && An(
|
18625 |
i,
|
@@ -18903,11 +18903,10 @@ function td(a) {
|
|
18903 |
}
|
18904 |
return s = p(a), i = f[s] = o[s](a), {
|
18905 |
c() {
|
18906 |
-
n = n0("div"), i.c(), Be(n, "class", "svelte-kqrm1b"),
|
18907 |
n,
|
18908 |
"thought",
|
18909 |
-
/*
|
18910 |
-
a[41].thought && /*thought_index*/
|
18911 |
a[43] > 0
|
18912 |
);
|
18913 |
},
|
@@ -18918,14 +18917,7 @@ function td(a) {
|
|
18918 |
let x = s;
|
18919 |
s = p(b), s === x ? f[s].p(b, y) : (A0(), Me(f[x], 1, 1, () => {
|
18920 |
f[x] = null;
|
18921 |
-
}), v0(), i = f[s], i ? i.p(b, y) : (i = f[s] = o[s](b), i.c()), _e(i, 1), i.m(n, null))
|
18922 |
-
1) && Je(
|
18923 |
-
n,
|
18924 |
-
"thought",
|
18925 |
-
/*message*/
|
18926 |
-
b[41].thought && /*thought_index*/
|
18927 |
-
b[43] > 0
|
18928 |
-
);
|
18929 |
},
|
18930 |
i(b) {
|
18931 |
u || (_e(i), u = !0);
|
@@ -19337,7 +19329,7 @@ function od(a) {
|
|
19337 |
}
|
19338 |
return ~(u = q(a)) && (o = B[u] = C[u](W(a, u))), {
|
19339 |
c() {
|
19340 |
-
x && x.c(), n = si(), s = n0("div"), i = n0("div"), o && o.c(), Be(i, "class", "message-wrap svelte-kqrm1b"),
|
19341 |
i,
|
19342 |
"bubble-gap",
|
19343 |
/*layout*/
|
@@ -19345,7 +19337,7 @@ function od(a) {
|
|
19345 |
), Be(s, "class", f = Oa(
|
19346 |
/*layout*/
|
19347 |
a[12] === "bubble" ? "bubble-wrap" : "panel-wrap"
|
19348 |
-
) + " svelte-kqrm1b"), Be(s, "role", "log"), Be(s, "aria-label", "chatbot conversation"), Be(s, "aria-live", "polite"),
|
19349 |
s,
|
19350 |
"placeholder-container",
|
19351 |
/*value*/
|
@@ -19368,7 +19360,7 @@ function od(a) {
|
|
19368 |
u = q(j), u === U ? ~u && B[u].p(W(j, u), G) : (o && (A0(), Me(B[U], 1, 1, () => {
|
19369 |
B[U] = null;
|
19370 |
}), v0()), ~u ? (o = B[u], o ? o.p(W(j, u), G) : (o = B[u] = C[u](W(j, u)), o.c()), _e(o, 1), o.m(i, null)) : o = null), (!p || G[0] & /*layout*/
|
19371 |
-
4096) &&
|
19372 |
i,
|
19373 |
"bubble-gap",
|
19374 |
/*layout*/
|
@@ -19378,7 +19370,7 @@ function od(a) {
|
|
19378 |
/*layout*/
|
19379 |
j[12] === "bubble" ? "bubble-wrap" : "panel-wrap"
|
19380 |
) + " svelte-kqrm1b")) && Be(s, "class", f), (!p || G[0] & /*layout, value*/
|
19381 |
-
4097) &&
|
19382 |
s,
|
19383 |
"placeholder-container",
|
19384 |
/*value*/
|
@@ -19402,9 +19394,9 @@ function ud(a) {
|
|
19402 |
}
|
19403 |
function cd(a) {
|
19404 |
const n = [];
|
19405 |
-
let s = [];
|
19406 |
-
for (const
|
19407 |
-
|
19408 |
return s.length > 0 && n.push(s), n;
|
19409 |
}
|
19410 |
function hd(a, n, s) {
|
|
|
2114 |
} catch {
|
2115 |
}
|
2116 |
}
|
2117 |
+
const Je = D.body || D.documentElement;
|
2118 |
+
return z && ne && Je.insertBefore(s.createTextNode(ne), Je.childNodes[0] || null), Ce === Nt ? J.call(D, ct ? "html" : "body")[0] : ct ? D.documentElement : Je;
|
2119 |
}, X = function(z) {
|
2120 |
return O.call(
|
2121 |
z.ownerDocument || z,
|
|
|
2148 |
if (!ie[ne] && w0(ne) && (be.tagNameCheck instanceof RegExp && ft(be.tagNameCheck, ne) || be.tagNameCheck instanceof Function && be.tagNameCheck(ne)))
|
2149 |
return !1;
|
2150 |
if (un && !S0[ne]) {
|
2151 |
+
const F = A(z) || z.parentNode, Je = U(z) || z.childNodes;
|
2152 |
+
if (Je && F) {
|
2153 |
+
const Qe = Je.length;
|
2154 |
for (let ot = Qe - 1; ot >= 0; --ot) {
|
2155 |
+
const $e = j(Je[ot], !0);
|
2156 |
+
$e.__removalCount = (z.__removalCount || 0) + 1, F.insertBefore($e, G(z));
|
2157 |
}
|
2158 |
}
|
2159 |
}
|
|
|
2209 |
};
|
2210 |
let F = D.length;
|
2211 |
for (; F--; ) {
|
2212 |
+
const Je = D[F], {
|
2213 |
name: Qe,
|
2214 |
namespaceURI: ot,
|
2215 |
+
value: $e
|
2216 |
+
} = Je, ue = je(Qe);
|
2217 |
+
let et = Qe === "value" ? $e : L4($e);
|
2218 |
+
if (ne.attrName = ue, ne.attrValue = et, ne.keepAttr = !0, ne.forceKeepAttr = void 0, De("uponSanitizeAttribute", z, ne), et = ne.attrValue, ne.forceKeepAttr || (h(Qe, z), !ne.keepAttr))
|
2219 |
continue;
|
2220 |
+
if (!bt && ft(/\/>/i, et)) {
|
2221 |
h(Qe, z);
|
2222 |
continue;
|
2223 |
}
|
2224 |
+
if (p0 && ft(/((--!?|])>)|<\/(style|title)/i, et)) {
|
2225 |
h(Qe, z);
|
2226 |
continue;
|
2227 |
}
|
2228 |
it && lr([ce, pe, ve], (dn) => {
|
2229 |
+
et = kn(et, dn, " ");
|
2230 |
});
|
2231 |
const P0 = je(z.nodeName);
|
2232 |
+
if (lt(P0, ue, et)) {
|
2233 |
+
if (O0 && (ue === "id" || ue === "name") && (h(Qe, z), et = Nn + et), S && typeof q == "object" && typeof q.getAttributeType == "function" && !ot)
|
2234 |
switch (q.getAttributeType(P0, ue)) {
|
2235 |
case "TrustedHTML": {
|
2236 |
+
et = S.createHTML(et);
|
2237 |
break;
|
2238 |
}
|
2239 |
case "TrustedScriptURL": {
|
2240 |
+
et = S.createScriptURL(et);
|
2241 |
break;
|
2242 |
}
|
2243 |
}
|
2244 |
try {
|
2245 |
+
ot ? z.setAttributeNS(ot, Qe, et) : z.setAttribute(Qe, et), w(z) ? ye(z) : Pl(n.removed);
|
2246 |
} catch {
|
2247 |
}
|
2248 |
}
|
|
|
2260 |
De("afterSanitizeShadowDOM", z, null);
|
2261 |
};
|
2262 |
return n.sanitize = function(re) {
|
2263 |
+
let z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, D = null, ne = null, F = null, Je = null;
|
2264 |
if (Q = !re, Q && (re = "<!-->"), typeof re != "string" && !E(re))
|
2265 |
if (typeof re.toString == "function") {
|
2266 |
if (re = re.toString(), typeof re != "string")
|
|
|
2271 |
return re;
|
2272 |
if (g0 || Lt(z), n.removed = [], typeof re == "string" && (b0 = !1), b0) {
|
2273 |
if (re.nodeName) {
|
2274 |
+
const $e = je(re.nodeName);
|
2275 |
+
if (!Fe[$e] || ie[$e])
|
2276 |
throw Dn("root node is forbidden and cannot be sanitized in-place");
|
2277 |
}
|
2278 |
} else if (re instanceof p)
|
|
|
2289 |
for (; F = Qe.nextNode(); ) {
|
2290 |
if (te(F))
|
2291 |
continue;
|
2292 |
+
const $e = A(F);
|
2293 |
+
F.nodeType === G0.element && ($e && $e.__depth ? F.__depth = (F.__removalCount || 0) + $e.__depth + 1 : F.__depth = 1), (F.__depth >= qn || F.__depth < 0 || Ul(F.__depth)) && ye(F), F.content instanceof o && (F.content.__depth = F.__depth, Xe(F.content)), oe(F);
|
2294 |
}
|
2295 |
if (b0)
|
2296 |
return re;
|
2297 |
if (vt) {
|
2298 |
if (K0)
|
2299 |
+
for (Je = H.call(D.ownerDocument); D.firstChild; )
|
2300 |
+
Je.appendChild(D.firstChild);
|
2301 |
else
|
2302 |
+
Je = D;
|
2303 |
+
return (he.shadowroot || he.shadowrootmode) && (Je = K.call(i, Je, !0)), Je;
|
2304 |
}
|
2305 |
let ot = ct ? D.outerHTML : D.innerHTML;
|
2306 |
return ct && Fe["!doctype"] && D.ownerDocument && D.ownerDocument.doctype && D.ownerDocument.doctype.name && ft(uo, D.ownerDocument.doctype.name) && (ot = "<!DOCTYPE " + D.ownerDocument.doctype.name + `>
|
2307 |
+
` + ot), it && lr([ce, pe, ve], ($e) => {
|
2308 |
+
ot = kn(ot, $e, " ");
|
2309 |
}), S && r0 ? S.createHTML(ot) : ot;
|
2310 |
}, n.setConfig = function() {
|
2311 |
let re = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
|
5922 |
}
|
5923 |
const d = "math", X = "text", w = "main", E = "ams", De = "accent-token", te = "bin", lt = "close", w0 = "inner", oe = "mathord", Xe = "op-token", re = "open", z = "punct", D = "rel", ne = "spacing", F = "textord";
|
5924 |
h(d, w, D, "≡", "\\equiv", !0), h(d, w, D, "≺", "\\prec", !0), h(d, w, D, "≻", "\\succ", !0), h(d, w, D, "∼", "\\sim", !0), h(d, w, D, "⊥", "\\perp"), h(d, w, D, "⪯", "\\preceq", !0), h(d, w, D, "⪰", "\\succeq", !0), h(d, w, D, "≃", "\\simeq", !0), h(d, w, D, "∣", "\\mid", !0), h(d, w, D, "≪", "\\ll", !0), h(d, w, D, "≫", "\\gg", !0), h(d, w, D, "≍", "\\asymp", !0), h(d, w, D, "∥", "\\parallel"), h(d, w, D, "⋈", "\\bowtie", !0), h(d, w, D, "⌣", "\\smile", !0), h(d, w, D, "⊑", "\\sqsubseteq", !0), h(d, w, D, "⊒", "\\sqsupseteq", !0), h(d, w, D, "≐", "\\doteq", !0), h(d, w, D, "⌢", "\\frown", !0), h(d, w, D, "∋", "\\ni", !0), h(d, w, D, "∝", "\\propto", !0), h(d, w, D, "⊢", "\\vdash", !0), h(d, w, D, "⊣", "\\dashv", !0), h(d, w, D, "∋", "\\owns"), h(d, w, z, ".", "\\ldotp"), h(d, w, z, "⋅", "\\cdotp"), h(d, w, F, "#", "\\#"), h(X, w, F, "#", "\\#"), h(d, w, F, "&", "\\&"), h(X, w, F, "&", "\\&"), h(d, w, F, "ℵ", "\\aleph", !0), h(d, w, F, "∀", "\\forall", !0), h(d, w, F, "ℏ", "\\hbar", !0), h(d, w, F, "∃", "\\exists", !0), h(d, w, F, "∇", "\\nabla", !0), h(d, w, F, "♭", "\\flat", !0), h(d, w, F, "ℓ", "\\ell", !0), h(d, w, F, "♮", "\\natural", !0), h(d, w, F, "♣", "\\clubsuit", !0), h(d, w, F, "℘", "\\wp", !0), h(d, w, F, "♯", "\\sharp", !0), h(d, w, F, "♢", "\\diamondsuit", !0), h(d, w, F, "ℜ", "\\Re", !0), h(d, w, F, "♡", "\\heartsuit", !0), h(d, w, F, "ℑ", "\\Im", !0), h(d, w, F, "♠", "\\spadesuit", !0), h(d, w, F, "§", "\\S", !0), h(X, w, F, "§", "\\S"), h(d, w, F, "¶", "\\P", !0), h(X, w, F, "¶", "\\P"), h(d, w, F, "†", "\\dag"), h(X, w, F, "†", "\\dag"), h(X, w, F, "†", "\\textdagger"), h(d, w, F, "‡", "\\ddag"), h(X, w, F, "‡", "\\ddag"), h(X, w, F, "‡", "\\textdaggerdbl"), h(d, w, lt, "⎱", "\\rmoustache", !0), h(d, w, re, "⎰", "\\lmoustache", !0), h(d, w, lt, "⟯", "\\rgroup", !0), h(d, w, re, "⟮", "\\lgroup", !0), h(d, w, te, "∓", "\\mp", !0), h(d, w, te, "⊖", "\\ominus", !0), h(d, w, te, "⊎", "\\uplus", !0), h(d, w, te, "⊓", "\\sqcap", !0), h(d, w, te, "∗", "\\ast"), h(d, w, te, "⊔", "\\sqcup", !0), h(d, w, te, "◯", "\\bigcirc", !0), h(d, w, te, "∙", "\\bullet", !0), h(d, w, te, "‡", "\\ddagger"), h(d, w, te, "≀", "\\wr", !0), h(d, w, te, "⨿", "\\amalg"), h(d, w, te, "&", "\\And"), h(d, w, D, "⟵", "\\longleftarrow", !0), h(d, w, D, "⇐", "\\Leftarrow", !0), h(d, w, D, "⟸", "\\Longleftarrow", !0), h(d, w, D, "⟶", "\\longrightarrow", !0), h(d, w, D, "⇒", "\\Rightarrow", !0), h(d, w, D, "⟹", "\\Longrightarrow", !0), h(d, w, D, "↔", "\\leftrightarrow", !0), h(d, w, D, "⟷", "\\longleftrightarrow", !0), h(d, w, D, "⇔", "\\Leftrightarrow", !0), h(d, w, D, "⟺", "\\Longleftrightarrow", !0), h(d, w, D, "↦", "\\mapsto", !0), h(d, w, D, "⟼", "\\longmapsto", !0), h(d, w, D, "↗", "\\nearrow", !0), h(d, w, D, "↩", "\\hookleftarrow", !0), h(d, w, D, "↪", "\\hookrightarrow", !0), h(d, w, D, "↘", "\\searrow", !0), h(d, w, D, "↼", "\\leftharpoonup", !0), h(d, w, D, "⇀", "\\rightharpoonup", !0), h(d, w, D, "↙", "\\swarrow", !0), h(d, w, D, "↽", "\\leftharpoondown", !0), h(d, w, D, "⇁", "\\rightharpoondown", !0), h(d, w, D, "↖", "\\nwarrow", !0), h(d, w, D, "⇌", "\\rightleftharpoons", !0), h(d, E, D, "≮", "\\nless", !0), h(d, E, D, "", "\\@nleqslant"), h(d, E, D, "", "\\@nleqq"), h(d, E, D, "⪇", "\\lneq", !0), h(d, E, D, "≨", "\\lneqq", !0), h(d, E, D, "", "\\@lvertneqq"), h(d, E, D, "⋦", "\\lnsim", !0), h(d, E, D, "⪉", "\\lnapprox", !0), h(d, E, D, "⊀", "\\nprec", !0), h(d, E, D, "⋠", "\\npreceq", !0), h(d, E, D, "⋨", "\\precnsim", !0), h(d, E, D, "⪹", "\\precnapprox", !0), h(d, E, D, "≁", "\\nsim", !0), h(d, E, D, "", "\\@nshortmid"), h(d, E, D, "∤", "\\nmid", !0), h(d, E, D, "⊬", "\\nvdash", !0), h(d, E, D, "⊭", "\\nvDash", !0), h(d, E, D, "⋪", "\\ntriangleleft"), h(d, E, D, "⋬", "\\ntrianglelefteq", !0), h(d, E, D, "⊊", "\\subsetneq", !0), h(d, E, D, "", "\\@varsubsetneq"), h(d, E, D, "⫋", "\\subsetneqq", !0), h(d, E, D, "", "\\@varsubsetneqq"), h(d, E, D, "≯", "\\ngtr", !0), h(d, E, D, "", "\\@ngeqslant"), h(d, E, D, "", "\\@ngeqq"), h(d, E, D, "⪈", "\\gneq", !0), h(d, E, D, "≩", "\\gneqq", !0), h(d, E, D, "", "\\@gvertneqq"), h(d, E, D, "⋧", "\\gnsim", !0), h(d, E, D, "⪊", "\\gnapprox", !0), h(d, E, D, "⊁", "\\nsucc", !0), h(d, E, D, "⋡", "\\nsucceq", !0), h(d, E, D, "⋩", "\\succnsim", !0), h(d, E, D, "⪺", "\\succnapprox", !0), h(d, E, D, "≆", "\\ncong", !0), h(d, E, D, "", "\\@nshortparallel"), h(d, E, D, "∦", "\\nparallel", !0), h(d, E, D, "⊯", "\\nVDash", !0), h(d, E, D, "⋫", "\\ntriangleright"), h(d, E, D, "⋭", "\\ntrianglerighteq", !0), h(d, E, D, "", "\\@nsupseteqq"), h(d, E, D, "⊋", "\\supsetneq", !0), h(d, E, D, "", "\\@varsupsetneq"), h(d, E, D, "⫌", "\\supsetneqq", !0), h(d, E, D, "", "\\@varsupsetneqq"), h(d, E, D, "⊮", "\\nVdash", !0), h(d, E, D, "⪵", "\\precneqq", !0), h(d, E, D, "⪶", "\\succneqq", !0), h(d, E, D, "", "\\@nsubseteqq"), h(d, E, te, "⊴", "\\unlhd"), h(d, E, te, "⊵", "\\unrhd"), h(d, E, D, "↚", "\\nleftarrow", !0), h(d, E, D, "↛", "\\nrightarrow", !0), h(d, E, D, "⇍", "\\nLeftarrow", !0), h(d, E, D, "⇏", "\\nRightarrow", !0), h(d, E, D, "↮", "\\nleftrightarrow", !0), h(d, E, D, "⇎", "\\nLeftrightarrow", !0), h(d, E, D, "△", "\\vartriangle"), h(d, E, F, "ℏ", "\\hslash"), h(d, E, F, "▽", "\\triangledown"), h(d, E, F, "◊", "\\lozenge"), h(d, E, F, "Ⓢ", "\\circledS"), h(d, E, F, "®", "\\circledR"), h(X, E, F, "®", "\\circledR"), h(d, E, F, "∡", "\\measuredangle", !0), h(d, E, F, "∄", "\\nexists"), h(d, E, F, "℧", "\\mho"), h(d, E, F, "Ⅎ", "\\Finv", !0), h(d, E, F, "⅁", "\\Game", !0), h(d, E, F, "‵", "\\backprime"), h(d, E, F, "▲", "\\blacktriangle"), h(d, E, F, "▼", "\\blacktriangledown"), h(d, E, F, "■", "\\blacksquare"), h(d, E, F, "⧫", "\\blacklozenge"), h(d, E, F, "★", "\\bigstar"), h(d, E, F, "∢", "\\sphericalangle", !0), h(d, E, F, "∁", "\\complement", !0), h(d, E, F, "ð", "\\eth", !0), h(X, w, F, "ð", "ð"), h(d, E, F, "╱", "\\diagup"), h(d, E, F, "╲", "\\diagdown"), h(d, E, F, "□", "\\square"), h(d, E, F, "□", "\\Box"), h(d, E, F, "◊", "\\Diamond"), h(d, E, F, "¥", "\\yen", !0), h(X, E, F, "¥", "\\yen", !0), h(d, E, F, "✓", "\\checkmark", !0), h(X, E, F, "✓", "\\checkmark"), h(d, E, F, "ℶ", "\\beth", !0), h(d, E, F, "ℸ", "\\daleth", !0), h(d, E, F, "ℷ", "\\gimel", !0), h(d, E, F, "ϝ", "\\digamma", !0), h(d, E, F, "ϰ", "\\varkappa"), h(d, E, re, "┌", "\\@ulcorner", !0), h(d, E, lt, "┐", "\\@urcorner", !0), h(d, E, re, "└", "\\@llcorner", !0), h(d, E, lt, "┘", "\\@lrcorner", !0), h(d, E, D, "≦", "\\leqq", !0), h(d, E, D, "⩽", "\\leqslant", !0), h(d, E, D, "⪕", "\\eqslantless", !0), h(d, E, D, "≲", "\\lesssim", !0), h(d, E, D, "⪅", "\\lessapprox", !0), h(d, E, D, "≊", "\\approxeq", !0), h(d, E, te, "⋖", "\\lessdot"), h(d, E, D, "⋘", "\\lll", !0), h(d, E, D, "≶", "\\lessgtr", !0), h(d, E, D, "⋚", "\\lesseqgtr", !0), h(d, E, D, "⪋", "\\lesseqqgtr", !0), h(d, E, D, "≑", "\\doteqdot"), h(d, E, D, "≓", "\\risingdotseq", !0), h(d, E, D, "≒", "\\fallingdotseq", !0), h(d, E, D, "∽", "\\backsim", !0), h(d, E, D, "⋍", "\\backsimeq", !0), h(d, E, D, "⫅", "\\subseteqq", !0), h(d, E, D, "⋐", "\\Subset", !0), h(d, E, D, "⊏", "\\sqsubset", !0), h(d, E, D, "≼", "\\preccurlyeq", !0), h(d, E, D, "⋞", "\\curlyeqprec", !0), h(d, E, D, "≾", "\\precsim", !0), h(d, E, D, "⪷", "\\precapprox", !0), h(d, E, D, "⊲", "\\vartriangleleft"), h(d, E, D, "⊴", "\\trianglelefteq"), h(d, E, D, "⊨", "\\vDash", !0), h(d, E, D, "⊪", "\\Vvdash", !0), h(d, E, D, "⌣", "\\smallsmile"), h(d, E, D, "⌢", "\\smallfrown"), h(d, E, D, "≏", "\\bumpeq", !0), h(d, E, D, "≎", "\\Bumpeq", !0), h(d, E, D, "≧", "\\geqq", !0), h(d, E, D, "⩾", "\\geqslant", !0), h(d, E, D, "⪖", "\\eqslantgtr", !0), h(d, E, D, "≳", "\\gtrsim", !0), h(d, E, D, "⪆", "\\gtrapprox", !0), h(d, E, te, "⋗", "\\gtrdot"), h(d, E, D, "⋙", "\\ggg", !0), h(d, E, D, "≷", "\\gtrless", !0), h(d, E, D, "⋛", "\\gtreqless", !0), h(d, E, D, "⪌", "\\gtreqqless", !0), h(d, E, D, "≖", "\\eqcirc", !0), h(d, E, D, "≗", "\\circeq", !0), h(d, E, D, "≜", "\\triangleq", !0), h(d, E, D, "∼", "\\thicksim"), h(d, E, D, "≈", "\\thickapprox"), h(d, E, D, "⫆", "\\supseteqq", !0), h(d, E, D, "⋑", "\\Supset", !0), h(d, E, D, "⊐", "\\sqsupset", !0), h(d, E, D, "≽", "\\succcurlyeq", !0), h(d, E, D, "⋟", "\\curlyeqsucc", !0), h(d, E, D, "��", "\\succsim", !0), h(d, E, D, "⪸", "\\succapprox", !0), h(d, E, D, "⊳", "\\vartriangleright"), h(d, E, D, "⊵", "\\trianglerighteq"), h(d, E, D, "⊩", "\\Vdash", !0), h(d, E, D, "∣", "\\shortmid"), h(d, E, D, "∥", "\\shortparallel"), h(d, E, D, "≬", "\\between", !0), h(d, E, D, "⋔", "\\pitchfork", !0), h(d, E, D, "∝", "\\varpropto"), h(d, E, D, "◀", "\\blacktriangleleft"), h(d, E, D, "∴", "\\therefore", !0), h(d, E, D, "∍", "\\backepsilon"), h(d, E, D, "▶", "\\blacktriangleright"), h(d, E, D, "∵", "\\because", !0), h(d, E, D, "⋘", "\\llless"), h(d, E, D, "⋙", "\\gggtr"), h(d, E, te, "⊲", "\\lhd"), h(d, E, te, "⊳", "\\rhd"), h(d, E, D, "≂", "\\eqsim", !0), h(d, w, D, "⋈", "\\Join"), h(d, E, D, "≑", "\\Doteq", !0), h(d, E, te, "∔", "\\dotplus", !0), h(d, E, te, "∖", "\\smallsetminus"), h(d, E, te, "⋒", "\\Cap", !0), h(d, E, te, "⋓", "\\Cup", !0), h(d, E, te, "⩞", "\\doublebarwedge", !0), h(d, E, te, "⊟", "\\boxminus", !0), h(d, E, te, "⊞", "\\boxplus", !0), h(d, E, te, "⋇", "\\divideontimes", !0), h(d, E, te, "⋉", "\\ltimes", !0), h(d, E, te, "⋊", "\\rtimes", !0), h(d, E, te, "⋋", "\\leftthreetimes", !0), h(d, E, te, "⋌", "\\rightthreetimes", !0), h(d, E, te, "⋏", "\\curlywedge", !0), h(d, E, te, "⋎", "\\curlyvee", !0), h(d, E, te, "⊝", "\\circleddash", !0), h(d, E, te, "⊛", "\\circledast", !0), h(d, E, te, "⋅", "\\centerdot"), h(d, E, te, "⊺", "\\intercal", !0), h(d, E, te, "⋒", "\\doublecap"), h(d, E, te, "⋓", "\\doublecup"), h(d, E, te, "⊠", "\\boxtimes", !0), h(d, E, D, "⇢", "\\dashrightarrow", !0), h(d, E, D, "⇠", "\\dashleftarrow", !0), h(d, E, D, "⇇", "\\leftleftarrows", !0), h(d, E, D, "⇆", "\\leftrightarrows", !0), h(d, E, D, "⇚", "\\Lleftarrow", !0), h(d, E, D, "↞", "\\twoheadleftarrow", !0), h(d, E, D, "↢", "\\leftarrowtail", !0), h(d, E, D, "↫", "\\looparrowleft", !0), h(d, E, D, "⇋", "\\leftrightharpoons", !0), h(d, E, D, "↶", "\\curvearrowleft", !0), h(d, E, D, "↺", "\\circlearrowleft", !0), h(d, E, D, "↰", "\\Lsh", !0), h(d, E, D, "⇈", "\\upuparrows", !0), h(d, E, D, "↿", "\\upharpoonleft", !0), h(d, E, D, "⇃", "\\downharpoonleft", !0), h(d, w, D, "⊶", "\\origof", !0), h(d, w, D, "⊷", "\\imageof", !0), h(d, E, D, "⊸", "\\multimap", !0), h(d, E, D, "↭", "\\leftrightsquigarrow", !0), h(d, E, D, "⇉", "\\rightrightarrows", !0), h(d, E, D, "⇄", "\\rightleftarrows", !0), h(d, E, D, "↠", "\\twoheadrightarrow", !0), h(d, E, D, "↣", "\\rightarrowtail", !0), h(d, E, D, "↬", "\\looparrowright", !0), h(d, E, D, "↷", "\\curvearrowright", !0), h(d, E, D, "↻", "\\circlearrowright", !0), h(d, E, D, "↱", "\\Rsh", !0), h(d, E, D, "⇊", "\\downdownarrows", !0), h(d, E, D, "↾", "\\upharpoonright", !0), h(d, E, D, "⇂", "\\downharpoonright", !0), h(d, E, D, "⇝", "\\rightsquigarrow", !0), h(d, E, D, "⇝", "\\leadsto"), h(d, E, D, "⇛", "\\Rrightarrow", !0), h(d, E, D, "↾", "\\restriction"), h(d, w, F, "‘", "`"), h(d, w, F, "$", "\\$"), h(X, w, F, "$", "\\$"), h(X, w, F, "$", "\\textdollar"), h(d, w, F, "%", "\\%"), h(X, w, F, "%", "\\%"), h(d, w, F, "_", "\\_"), h(X, w, F, "_", "\\_"), h(X, w, F, "_", "\\textunderscore"), h(d, w, F, "∠", "\\angle", !0), h(d, w, F, "∞", "\\infty", !0), h(d, w, F, "′", "\\prime"), h(d, w, F, "△", "\\triangle"), h(d, w, F, "Γ", "\\Gamma", !0), h(d, w, F, "Δ", "\\Delta", !0), h(d, w, F, "Θ", "\\Theta", !0), h(d, w, F, "Λ", "\\Lambda", !0), h(d, w, F, "Ξ", "\\Xi", !0), h(d, w, F, "Π", "\\Pi", !0), h(d, w, F, "Σ", "\\Sigma", !0), h(d, w, F, "Υ", "\\Upsilon", !0), h(d, w, F, "Φ", "\\Phi", !0), h(d, w, F, "Ψ", "\\Psi", !0), h(d, w, F, "Ω", "\\Omega", !0), h(d, w, F, "A", "Α"), h(d, w, F, "B", "Β"), h(d, w, F, "E", "Ε"), h(d, w, F, "Z", "Ζ"), h(d, w, F, "H", "Η"), h(d, w, F, "I", "Ι"), h(d, w, F, "K", "Κ"), h(d, w, F, "M", "Μ"), h(d, w, F, "N", "Ν"), h(d, w, F, "O", "Ο"), h(d, w, F, "P", "Ρ"), h(d, w, F, "T", "Τ"), h(d, w, F, "X", "Χ"), h(d, w, F, "¬", "\\neg", !0), h(d, w, F, "¬", "\\lnot"), h(d, w, F, "⊤", "\\top"), h(d, w, F, "⊥", "\\bot"), h(d, w, F, "∅", "\\emptyset"), h(d, E, F, "∅", "\\varnothing"), h(d, w, oe, "α", "\\alpha", !0), h(d, w, oe, "β", "\\beta", !0), h(d, w, oe, "γ", "\\gamma", !0), h(d, w, oe, "δ", "\\delta", !0), h(d, w, oe, "ϵ", "\\epsilon", !0), h(d, w, oe, "ζ", "\\zeta", !0), h(d, w, oe, "η", "\\eta", !0), h(d, w, oe, "θ", "\\theta", !0), h(d, w, oe, "ι", "\\iota", !0), h(d, w, oe, "κ", "\\kappa", !0), h(d, w, oe, "λ", "\\lambda", !0), h(d, w, oe, "μ", "\\mu", !0), h(d, w, oe, "ν", "\\nu", !0), h(d, w, oe, "ξ", "\\xi", !0), h(d, w, oe, "ο", "\\omicron", !0), h(d, w, oe, "π", "\\pi", !0), h(d, w, oe, "ρ", "\\rho", !0), h(d, w, oe, "σ", "\\sigma", !0), h(d, w, oe, "τ", "\\tau", !0), h(d, w, oe, "υ", "\\upsilon", !0), h(d, w, oe, "ϕ", "\\phi", !0), h(d, w, oe, "χ", "\\chi", !0), h(d, w, oe, "ψ", "\\psi", !0), h(d, w, oe, "ω", "\\omega", !0), h(d, w, oe, "ε", "\\varepsilon", !0), h(d, w, oe, "ϑ", "\\vartheta", !0), h(d, w, oe, "ϖ", "\\varpi", !0), h(d, w, oe, "ϱ", "\\varrho", !0), h(d, w, oe, "ς", "\\varsigma", !0), h(d, w, oe, "φ", "\\varphi", !0), h(d, w, te, "∗", "*", !0), h(d, w, te, "+", "+"), h(d, w, te, "−", "-", !0), h(d, w, te, "⋅", "\\cdot", !0), h(d, w, te, "∘", "\\circ", !0), h(d, w, te, "÷", "\\div", !0), h(d, w, te, "±", "\\pm", !0), h(d, w, te, "×", "\\times", !0), h(d, w, te, "∩", "\\cap", !0), h(d, w, te, "∪", "\\cup", !0), h(d, w, te, "∖", "\\setminus", !0), h(d, w, te, "∧", "\\land"), h(d, w, te, "∨", "\\lor"), h(d, w, te, "∧", "\\wedge", !0), h(d, w, te, "∨", "\\vee", !0), h(d, w, F, "√", "\\surd"), h(d, w, re, "⟨", "\\langle", !0), h(d, w, re, "∣", "\\lvert"), h(d, w, re, "∥", "\\lVert"), h(d, w, lt, "?", "?"), h(d, w, lt, "!", "!"), h(d, w, lt, "⟩", "\\rangle", !0), h(d, w, lt, "∣", "\\rvert"), h(d, w, lt, "∥", "\\rVert"), h(d, w, D, "=", "="), h(d, w, D, ":", ":"), h(d, w, D, "≈", "\\approx", !0), h(d, w, D, "≅", "\\cong", !0), h(d, w, D, "≥", "\\ge"), h(d, w, D, "≥", "\\geq", !0), h(d, w, D, "←", "\\gets"), h(d, w, D, ">", "\\gt", !0), h(d, w, D, "∈", "\\in", !0), h(d, w, D, "", "\\@not"), h(d, w, D, "⊂", "\\subset", !0), h(d, w, D, "⊃", "\\supset", !0), h(d, w, D, "⊆", "\\subseteq", !0), h(d, w, D, "⊇", "\\supseteq", !0), h(d, E, D, "⊈", "\\nsubseteq", !0), h(d, E, D, "⊉", "\\nsupseteq", !0), h(d, w, D, "⊨", "\\models"), h(d, w, D, "←", "\\leftarrow", !0), h(d, w, D, "≤", "\\le"), h(d, w, D, "≤", "\\leq", !0), h(d, w, D, "<", "\\lt", !0), h(d, w, D, "→", "\\rightarrow", !0), h(d, w, D, "→", "\\to"), h(d, E, D, "≱", "\\ngeq", !0), h(d, E, D, "≰", "\\nleq", !0), h(d, w, ne, " ", "\\ "), h(d, w, ne, " ", "\\space"), h(d, w, ne, " ", "\\nobreakspace"), h(X, w, ne, " ", "\\ "), h(X, w, ne, " ", " "), h(X, w, ne, " ", "\\space"), h(X, w, ne, " ", "\\nobreakspace"), h(d, w, ne, null, "\\nobreak"), h(d, w, ne, null, "\\allowbreak"), h(d, w, z, ",", ","), h(d, w, z, ";", ";"), h(d, E, te, "⊼", "\\barwedge", !0), h(d, E, te, "⊻", "\\veebar", !0), h(d, w, te, "⊙", "\\odot", !0), h(d, w, te, "⊕", "\\oplus", !0), h(d, w, te, "⊗", "\\otimes", !0), h(d, w, F, "∂", "\\partial", !0), h(d, w, te, "⊘", "\\oslash", !0), h(d, E, te, "⊚", "\\circledcirc", !0), h(d, E, te, "⊡", "\\boxdot", !0), h(d, w, te, "△", "\\bigtriangleup"), h(d, w, te, "▽", "\\bigtriangledown"), h(d, w, te, "†", "\\dagger"), h(d, w, te, "⋄", "\\diamond"), h(d, w, te, "⋆", "\\star"), h(d, w, te, "◃", "\\triangleleft"), h(d, w, te, "▹", "\\triangleright"), h(d, w, re, "{", "\\{"), h(X, w, F, "{", "\\{"), h(X, w, F, "{", "\\textbraceleft"), h(d, w, lt, "}", "\\}"), h(X, w, F, "}", "\\}"), h(X, w, F, "}", "\\textbraceright"), h(d, w, re, "{", "\\lbrace"), h(d, w, lt, "}", "\\rbrace"), h(d, w, re, "[", "\\lbrack", !0), h(X, w, F, "[", "\\lbrack", !0), h(d, w, lt, "]", "\\rbrack", !0), h(X, w, F, "]", "\\rbrack", !0), h(d, w, re, "(", "\\lparen", !0), h(d, w, lt, ")", "\\rparen", !0), h(X, w, F, "<", "\\textless", !0), h(X, w, F, ">", "\\textgreater", !0), h(d, w, re, "⌊", "\\lfloor", !0), h(d, w, lt, "⌋", "\\rfloor", !0), h(d, w, re, "⌈", "\\lceil", !0), h(d, w, lt, "⌉", "\\rceil", !0), h(d, w, F, "\\", "\\backslash"), h(d, w, F, "∣", "|"), h(d, w, F, "∣", "\\vert"), h(X, w, F, "|", "\\textbar", !0), h(d, w, F, "∥", "\\|"), h(d, w, F, "∥", "\\Vert"), h(X, w, F, "∥", "\\textbardbl"), h(X, w, F, "~", "\\textasciitilde"), h(X, w, F, "\\", "\\textbackslash"), h(X, w, F, "^", "\\textasciicircum"), h(d, w, D, "↑", "\\uparrow", !0), h(d, w, D, "⇑", "\\Uparrow", !0), h(d, w, D, "↓", "\\downarrow", !0), h(d, w, D, "⇓", "\\Downarrow", !0), h(d, w, D, "↕", "\\updownarrow", !0), h(d, w, D, "⇕", "\\Updownarrow", !0), h(d, w, Xe, "∐", "\\coprod"), h(d, w, Xe, "⋁", "\\bigvee"), h(d, w, Xe, "⋀", "\\bigwedge"), h(d, w, Xe, "⨄", "\\biguplus"), h(d, w, Xe, "⋂", "\\bigcap"), h(d, w, Xe, "⋃", "\\bigcup"), h(d, w, Xe, "∫", "\\int"), h(d, w, Xe, "∫", "\\intop"), h(d, w, Xe, "∬", "\\iint"), h(d, w, Xe, "∭", "\\iiint"), h(d, w, Xe, "∏", "\\prod"), h(d, w, Xe, "∑", "\\sum"), h(d, w, Xe, "⨂", "\\bigotimes"), h(d, w, Xe, "⨁", "\\bigoplus"), h(d, w, Xe, "⨀", "\\bigodot"), h(d, w, Xe, "∮", "\\oint"), h(d, w, Xe, "∯", "\\oiint"), h(d, w, Xe, "∰", "\\oiiint"), h(d, w, Xe, "⨆", "\\bigsqcup"), h(d, w, Xe, "∫", "\\smallint"), h(X, w, w0, "…", "\\textellipsis"), h(d, w, w0, "…", "\\mathellipsis"), h(X, w, w0, "…", "\\ldots", !0), h(d, w, w0, "…", "\\ldots", !0), h(d, w, w0, "⋯", "\\@cdots", !0), h(d, w, w0, "⋱", "\\ddots", !0), h(d, w, F, "⋮", "\\varvdots"), h(d, w, De, "ˊ", "\\acute"), h(d, w, De, "ˋ", "\\grave"), h(d, w, De, "¨", "\\ddot"), h(d, w, De, "~", "\\tilde"), h(d, w, De, "ˉ", "\\bar"), h(d, w, De, "˘", "\\breve"), h(d, w, De, "ˇ", "\\check"), h(d, w, De, "^", "\\hat"), h(d, w, De, "⃗", "\\vec"), h(d, w, De, "˙", "\\dot"), h(d, w, De, "˚", "\\mathring"), h(d, w, oe, "", "\\@imath"), h(d, w, oe, "", "\\@jmath"), h(d, w, F, "ı", "ı"), h(d, w, F, "ȷ", "ȷ"), h(X, w, F, "ı", "\\i", !0), h(X, w, F, "ȷ", "\\j", !0), h(X, w, F, "ß", "\\ss", !0), h(X, w, F, "æ", "\\ae", !0), h(X, w, F, "œ", "\\oe", !0), h(X, w, F, "ø", "\\o", !0), h(X, w, F, "Æ", "\\AE", !0), h(X, w, F, "Œ", "\\OE", !0), h(X, w, F, "Ø", "\\O", !0), h(X, w, De, "ˊ", "\\'"), h(X, w, De, "ˋ", "\\`"), h(X, w, De, "ˆ", "\\^"), h(X, w, De, "˜", "\\~"), h(X, w, De, "ˉ", "\\="), h(X, w, De, "˘", "\\u"), h(X, w, De, "˙", "\\."), h(X, w, De, "¸", "\\c"), h(X, w, De, "˚", "\\r"), h(X, w, De, "ˇ", "\\v"), h(X, w, De, "¨", '\\"'), h(X, w, De, "˝", "\\H"), h(X, w, De, "◯", "\\textcircled");
|
5925 |
+
const Je = {
|
5926 |
"--": !0,
|
5927 |
"---": !0,
|
5928 |
"``": !0,
|
|
|
5939 |
const e = ot.charAt(t);
|
5940 |
h(X, w, F, e, e);
|
5941 |
}
|
5942 |
+
const $e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
5943 |
+
for (let t = 0; t < $e.length; t++) {
|
5944 |
+
const e = $e.charAt(t);
|
5945 |
h(d, w, oe, e, e), h(X, w, F, e, e);
|
5946 |
}
|
5947 |
h(d, E, F, "C", "ℂ"), h(X, E, F, "C", "ℂ"), h(d, E, F, "H", "ℍ"), h(X, E, F, "H", "ℍ"), h(d, E, F, "N", "ℕ"), h(X, E, F, "N", "ℕ"), h(d, E, F, "P", "ℙ"), h(X, E, F, "P", "ℙ"), h(d, E, F, "Q", "ℚ"), h(X, E, F, "Q", "ℚ"), h(d, E, F, "R", "ℝ"), h(X, E, F, "R", "ℝ"), h(d, E, F, "Z", "ℤ"), h(X, E, F, "Z", "ℤ"), h(d, w, oe, "h", "ℎ"), h(X, w, oe, "h", "ℎ");
|
5948 |
let ue = "";
|
5949 |
+
for (let t = 0; t < $e.length; t++) {
|
5950 |
+
const e = $e.charAt(t);
|
5951 |
ue = String.fromCharCode(55349, 56320 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56372 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56424 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56580 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56684 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56736 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56788 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56840 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56944 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), t < 26 && (ue = String.fromCharCode(55349, 56632 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 56476 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue));
|
5952 |
}
|
5953 |
ue = "𝕜", h(d, w, oe, "k", ue), h(X, w, F, "k", ue);
|
|
|
5955 |
const e = t.toString();
|
5956 |
ue = String.fromCharCode(55349, 57294 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57314 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57324 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue), ue = String.fromCharCode(55349, 57334 + t), h(d, w, oe, e, ue), h(X, w, F, e, ue);
|
5957 |
}
|
5958 |
+
const et = "ÐÞþ";
|
5959 |
+
for (let t = 0; t < et.length; t++) {
|
5960 |
+
const e = et.charAt(t);
|
5961 |
h(d, w, oe, e, e), h(X, w, F, e, e);
|
5962 |
}
|
5963 |
const P0 = [
|
|
|
6086 |
g ? (N = ai[_].fontName, R = [_]) : (N = Gn(_, e.fontWeight, e.fontShape), R = [_, e.fontWeight, e.fontShape]);
|
6087 |
if (Un(c, N, l).metrics)
|
6088 |
return Zt(c, N, l, e, m.concat(R));
|
6089 |
+
if (Je.hasOwnProperty(c) && N.slice(0, 10) === "Typewriter") {
|
6090 |
const P = [];
|
6091 |
for (let Y = 0; Y < c.length; Y++)
|
6092 |
P.push(Zt(c[Y], N, l, e, m.concat(R)));
|
|
|
6482 |
mclose: "mclose",
|
6483 |
mpunct: "mpunct",
|
6484 |
minner: "minner"
|
6485 |
+
}, tt = function(t, e, r, l) {
|
6486 |
l === void 0 && (l = [null, null]);
|
6487 |
const c = [];
|
6488 |
for (let T = 0; T < t.length; T++) {
|
|
|
6572 |
function qr(t, e) {
|
6573 |
let r = null;
|
6574 |
t.length === 1 && t[0].type === "tag" && (r = t[0].tag, t = t[0].body);
|
6575 |
+
const l = tt(t, e, "root");
|
6576 |
let c;
|
6577 |
l.length === 2 && l[1].hasClass("tag") && (c = l.pop());
|
6578 |
const m = [];
|
|
|
6587 |
l[T].hasClass("newline") && (g.pop(), g.length > 0 && (m.push(Xn(g, e)), g = []), m.push(l[T]));
|
6588 |
g.length > 0 && m.push(Xn(g, e));
|
6589 |
let _;
|
6590 |
+
r ? (_ = Xn(tt(r, e, !0)), _.classes = ["tag"], m.push(_)) : c && m.push(c);
|
6591 |
const v = _0(["katex-html"], m);
|
6592 |
if (v.setAttribute("aria-hidden", "true"), _) {
|
6593 |
const T = _.children[0];
|
|
|
6709 |
newDocumentFragment: hi
|
6710 |
};
|
6711 |
const qt = function(t, e, r) {
|
6712 |
+
return ye[e][t] && ye[e][t].replace && t.charCodeAt(0) !== 55349 && !(Je.hasOwnProperty(t) && r && (r.fontFamily && r.fontFamily.slice(4, 6) === "tt" || r.font && r.font.slice(4, 6) === "tt")) && (t = ye[e][t].replace), new Z.TextNode(t);
|
6713 |
}, Pr = function(t) {
|
6714 |
return t.length === 1 ? t[0] : new Z.MathNode("mrow", t);
|
6715 |
}, Hr = function(t, e) {
|
|
|
7303 |
});
|
7304 |
const wu = L.makeSpan;
|
7305 |
function gi(t, e) {
|
7306 |
+
const r = tt(t.body, e, !0);
|
7307 |
return wu([t.mclass], r, e);
|
7308 |
}
|
7309 |
function bi(t, e) {
|
|
|
7417 |
};
|
7418 |
},
|
7419 |
htmlBuilder(t, e) {
|
7420 |
+
const r = tt(t.body, e, !0), l = L.makeSpan([t.mclass], r, e);
|
7421 |
return l.style.textShadow = "0.02em 0.01em 0.04px", l;
|
7422 |
},
|
7423 |
mathmlBuilder(t, e) {
|
|
|
7638 |
}
|
7639 |
});
|
7640 |
const _i = (t, e) => {
|
7641 |
+
const r = tt(t.body, e.withColor(t.color), !1);
|
7642 |
return L.makeFragment(r);
|
7643 |
}, ki = (t, e) => {
|
7644 |
const r = _t(t.body, e.withColor(t.color)), l = new Z.MathNode("mstyle", r);
|
|
|
7919 |
const Ye = gn(_, P, c);
|
7920 |
Te = Ye.height + Ye.depth, qe = 2;
|
7921 |
}
|
7922 |
+
const ht = se + xe + Te, nt = Math.max(0, Math.ceil((e - ht) / (qe * ke))), Ht = ht + nt * qe * ke;
|
7923 |
let tn = l.fontMetrics().axisHeight;
|
7924 |
r && (tn *= l.sizeMultiplier);
|
7925 |
const Se = Ht / 2 - tn, ze = [];
|
|
|
8229 |
},
|
8230 |
htmlBuilder: (t, e) => {
|
8231 |
Bi(t);
|
8232 |
+
const r = tt(t.body, e, !0, ["mopen", "mclose"]);
|
8233 |
let l = 0, c = 0, m = !1;
|
8234 |
for (let v = 0; v < r.length; v++)
|
8235 |
r[v].isMiddle ? m = !0 : (l = Math.max(r[v].height, l), c = Math.max(r[v].depth, c));
|
|
|
8649 |
break;
|
8650 |
} else if (ht === "\\\\") {
|
8651 |
t.consume();
|
8652 |
+
let nt;
|
8653 |
+
t.gullet.future().text !== " " && (nt = t.parseSizeGroup(!0)), ae.push(nt ? nt.value : null), Te(), ke.push(Ii(t)), Y = [], se.push(Y), xe();
|
8654 |
} else
|
8655 |
throw new o("Expected & or \\\\ or \\cr or \\end", t.nextToken);
|
8656 |
}
|
|
|
8710 |
Ye && (Ve = Ce(Ye, e), Ve > 0 && (Ve += ke, Pe < Ve && (Pe = Ve), Ve = 0)), t.addJot && (Pe += Y), Ue.height = ze, Ue.depth = Pe, ge += ze, Ue.pos = ge, ge += Pe + Ve, _[r] = Ue, xe(m[r + 1]);
|
8711 |
}
|
8712 |
const Te = ge / 2 + e.fontMetrics().axisHeight, qe = t.cols || [], ht = [];
|
8713 |
+
let nt, Ht;
|
8714 |
const tn = [];
|
8715 |
if (t.tags && t.tags.some((Se) => Se))
|
8716 |
for (r = 0; r < c; ++r) {
|
8717 |
const Se = _[r], ze = Se.pos - Te, Pe = t.tags[r];
|
8718 |
let Ue;
|
8719 |
+
Pe === !0 ? Ue = L.makeSpan(["eqn-num"], [], e) : Pe === !1 ? Ue = L.makeSpan([], [], e) : Ue = L.makeSpan([], tt(Pe, e, !0), e), Ue.depth = Se.depth, Ue.height = Se.height, tn.push({
|
8720 |
type: "elem",
|
8721 |
elem: Ue,
|
8722 |
shift: ze
|
|
|
8731 |
) {
|
8732 |
let Se = qe[Ht] || {}, ze = !0;
|
8733 |
for (; Se.type === "separator"; ) {
|
8734 |
+
if (ze || (nt = L.makeSpan(["arraycolsep"], []), nt.style.width = Q(e.fontMetrics().doubleRuleSep), ht.push(nt)), Se.separator === "|" || Se.separator === ":") {
|
8735 |
const Ye = Se.separator === "|" ? "solid" : "dashed", Ve = L.makeSpan(["vertical-separator"], [], e);
|
8736 |
Ve.style.height = Q(ge), Ve.style.borderRightWidth = Q(T), Ve.style.borderRightStyle = Ye, Ve.style.margin = "0 " + Q(-T / 2);
|
8737 |
const Ut = ge - Te;
|
|
|
8743 |
if (l >= g)
|
8744 |
continue;
|
8745 |
let Pe;
|
8746 |
+
(l > 0 || t.hskipBeforeAndAfter) && (Pe = U.deflt(Se.pregap, R), Pe !== 0 && (nt = L.makeSpan(["arraycolsep"], []), nt.style.width = Q(Pe), ht.push(nt)));
|
8747 |
let Ue = [];
|
8748 |
for (r = 0; r < c; ++r) {
|
8749 |
const Ye = _[r], Ve = Ye[l];
|
|
|
8759 |
Ue = L.makeVList({
|
8760 |
positionType: "individualShift",
|
8761 |
children: Ue
|
8762 |
+
}, e), Ue = L.makeSpan(["col-align-" + (Se.align || "c")], [Ue]), ht.push(Ue), (l < g - 1 || t.hskipBeforeAndAfter) && (Pe = U.deflt(Se.postgap, R), Pe !== 0 && (nt = L.makeSpan(["arraycolsep"], []), nt.style.width = Q(Pe), ht.push(nt)));
|
8763 |
}
|
8764 |
if (_ = L.makeSpan(["mtable"], ht), v.length > 0) {
|
8765 |
const Se = L.makeLineSpan("hline", e, T), ze = L.makeLineSpan("hdashline", e, T), Pe = [{
|
|
|
9709 |
} : r.formatUnsupportedCmd("\\href");
|
9710 |
},
|
9711 |
htmlBuilder: (t, e) => {
|
9712 |
+
const r = tt(t.body, e, !1);
|
9713 |
return L.makeAnchor(t.href, [], r, e);
|
9714 |
},
|
9715 |
mathmlBuilder: (t, e) => {
|
|
|
9776 |
};
|
9777 |
},
|
9778 |
htmlBuilder(t, e) {
|
9779 |
+
const r = tt(t.body, e, !1);
|
9780 |
return L.makeFragment(r);
|
9781 |
},
|
9782 |
mathmlBuilder(t, e) {
|
|
|
9844 |
} : r.formatUnsupportedCmd(l);
|
9845 |
},
|
9846 |
htmlBuilder: (t, e) => {
|
9847 |
+
const r = tt(t.body, e, !1), l = ["enclosing"];
|
9848 |
t.attributes.class && l.push(...t.attributes.class.trim().split(/\s+/));
|
9849 |
const c = L.makeSpan(l, r, e);
|
9850 |
for (const m in t.attributes)
|
|
|
9871 |
};
|
9872 |
},
|
9873 |
htmlBuilder: (t, e) => {
|
9874 |
+
const r = tt(t.html, e, !1);
|
9875 |
return L.makeFragment(r);
|
9876 |
},
|
9877 |
mathmlBuilder: (t, e) => C0(t.mathml, e)
|
|
|
10120 |
};
|
10121 |
},
|
10122 |
htmlBuilder: (t, e) => {
|
10123 |
+
const r = ji(t, e), l = tt(r, e, !1);
|
10124 |
return L.makeFragment(l);
|
10125 |
},
|
10126 |
mathmlBuilder: (t, e) => {
|
|
|
10251 |
}, e), m.name = "\\" + P, v.classes.unshift("mop"), v.italic = Y;
|
10252 |
}
|
10253 |
} else if (m.body) {
|
10254 |
+
const R = tt(m.body, e, !0);
|
10255 |
R.length === 1 && R[0] instanceof wt ? (v = R[0], v.classes[0] = "mop") : v = L.makeSpan(["mop"], R, e);
|
10256 |
} else {
|
10257 |
const R = [];
|
|
|
10420 |
mode: T.mode,
|
10421 |
text: N
|
10422 |
} : T;
|
10423 |
+
}), v = tt(_, e.withFont("mathrm"), !0);
|
10424 |
for (let T = 0; T < v.length; T++) {
|
10425 |
const N = v[T];
|
10426 |
N instanceof wt && (N.text = N.text.replace(/\u2212/, "-").replace(/\u2217/, "*"));
|
|
|
10488 |
}), k("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"), U0({
|
10489 |
type: "ordgroup",
|
10490 |
htmlBuilder(t, e) {
|
10491 |
+
return t.semisimple ? L.makeFragment(tt(t.body, e, !1)) : L.makeSpan(["mord"], tt(t.body, e, !0), e);
|
10492 |
},
|
10493 |
mathmlBuilder(t, e) {
|
10494 |
return C0(t.body, e, !0);
|
|
|
10554 |
};
|
10555 |
},
|
10556 |
htmlBuilder: (t, e) => {
|
10557 |
+
const r = tt(t.body, e.withPhantom(), !1);
|
10558 |
return L.makeFragment(r);
|
10559 |
},
|
10560 |
mathmlBuilder: (t, e) => {
|
|
|
10706 |
}
|
10707 |
});
|
10708 |
function Ki(t, e, r) {
|
10709 |
+
const l = tt(t, e, !1), c = e.sizeMultiplier / r.sizeMultiplier;
|
10710 |
for (let m = 0; m < l.length; m++) {
|
10711 |
const g = l[m].classes.indexOf("sizing");
|
10712 |
g < 0 ? Array.prototype.push.apply(l[m].classes, e.sizingClasses(r)) : l[m].classes[g + 1] === "reset-size" + e.size && (l[m].classes[g + 1] = "reset-size" + r.size), l[m].height *= c, l[m].depth *= c;
|
|
|
10959 |
const qe = 4 * T.defaultRuleThickness;
|
10960 |
if (N - _.depth - (v.height - R) < qe) {
|
10961 |
R = qe - (N - _.depth) + v.height;
|
10962 |
+
const nt = 0.8 * T.xHeight - (N - _.depth);
|
10963 |
+
nt > 0 && (N += nt, R -= nt);
|
10964 |
}
|
10965 |
const ht = [{
|
10966 |
type: "elem",
|
|
|
11173 |
};
|
11174 |
},
|
11175 |
htmlBuilder(t, e) {
|
11176 |
+
const r = rl(t, e), l = tt(t.body, r, !0);
|
11177 |
return L.makeSpan(["mord", "text"], l, r);
|
11178 |
},
|
11179 |
mathmlBuilder(t, e) {
|
|
|
12977 |
l && (r = r.substring(0, l.index), r === "i" ? r = "ı" : r === "j" && (r = "ȷ"));
|
12978 |
let c;
|
12979 |
if (ye[this.mode][r]) {
|
12980 |
+
this.settings.strict && this.mode === "math" && et.indexOf(r) >= 0 && this.settings.reportNonstrict("unicodeTextInMathMode", 'Latin-1/Unicode text character "' + r[0] + '" used in math mode', e);
|
12981 |
const m = ye[this.mode][r].group, g = Et.range(e);
|
12982 |
let _;
|
12983 |
if (Pn.hasOwnProperty(m)) {
|
|
|
18269 |
set_style: An,
|
18270 |
space: si,
|
18271 |
text: Vf,
|
18272 |
+
toggle_class: rt,
|
18273 |
transition_in: _e,
|
18274 |
transition_out: Me
|
18275 |
} = window.__gradio__svelte__internal, { beforeUpdate: Wf, afterUpdate: jf, createEventDispatcher: Xf } = window.__gradio__svelte__internal;
|
|
|
18498 |
W[A].c();
|
18499 |
Be(u, "data-testid", o = /*role*/
|
18500 |
a[39]), Be(u, "dir", f = /*rtl*/
|
18501 |
+
a[5] ? "rtl" : "ltr"), Be(u, "class", "svelte-kqrm1b"), rt(
|
18502 |
u,
|
18503 |
"latest",
|
18504 |
/*i*/
|
18505 |
a[38] === /*groupedMessages*/
|
18506 |
a[35].length - 1
|
18507 |
+
), rt(u, "message-markdown-disabled", !/*render_markdown*/
|
18508 |
+
a[9]), rt(
|
18509 |
u,
|
18510 |
"selectable",
|
18511 |
/*selectable*/
|
|
|
18516 |
/*rtl*/
|
18517 |
a[5] ? "right" : "left"
|
18518 |
), Be(i, "class", p = "message " + /*role*/
|
18519 |
+
(a[39] === "user" ? "user" : "bot") + " svelte-kqrm1b"), rt(
|
18520 |
i,
|
18521 |
"message-fit",
|
18522 |
/*layout*/
|
18523 |
a[12] === "bubble" && !/*bubble_full_width*/
|
18524 |
a[8]
|
18525 |
+
), rt(
|
18526 |
i,
|
18527 |
"panel-full-width",
|
18528 |
/*layout*/
|
18529 |
a[12] === "panel"
|
18530 |
+
), rt(
|
18531 |
i,
|
18532 |
"message-bubble-border",
|
18533 |
/*layout*/
|
18534 |
a[12] === "bubble"
|
18535 |
+
), rt(i, "message-markdown-disabled", !/*render_markdown*/
|
18536 |
a[9]), An(
|
18537 |
i,
|
18538 |
"text-align",
|
|
|
18577 |
a[39])) && Be(u, "data-testid", o), (!y || S[0] & /*rtl*/
|
18578 |
32 && f !== (f = /*rtl*/
|
18579 |
a[5] ? "rtl" : "ltr")) && Be(u, "dir", f), (!y || S[0] & /*value*/
|
18580 |
+
1) && rt(
|
18581 |
u,
|
18582 |
"latest",
|
18583 |
/*i*/
|
18584 |
a[38] === /*groupedMessages*/
|
18585 |
a[35].length - 1
|
18586 |
), (!y || S[0] & /*render_markdown*/
|
18587 |
+
512) && rt(u, "message-markdown-disabled", !/*render_markdown*/
|
18588 |
a[9]), (!y || S[0] & /*selectable*/
|
18589 |
+
8) && rt(
|
18590 |
u,
|
18591 |
"selectable",
|
18592 |
/*selectable*/
|
|
|
18600 |
), (!y || S[0] & /*value*/
|
18601 |
1 && p !== (p = "message " + /*role*/
|
18602 |
(a[39] === "user" ? "user" : "bot") + " svelte-kqrm1b")) && Be(i, "class", p), (!y || S[0] & /*value, layout, bubble_full_width*/
|
18603 |
+
4353) && rt(
|
18604 |
i,
|
18605 |
"message-fit",
|
18606 |
/*layout*/
|
18607 |
a[12] === "bubble" && !/*bubble_full_width*/
|
18608 |
a[8]
|
18609 |
), (!y || S[0] & /*value, layout*/
|
18610 |
+
4097) && rt(
|
18611 |
i,
|
18612 |
"panel-full-width",
|
18613 |
/*layout*/
|
18614 |
a[12] === "panel"
|
18615 |
), (!y || S[0] & /*value, layout*/
|
18616 |
+
4097) && rt(
|
18617 |
i,
|
18618 |
"message-bubble-border",
|
18619 |
/*layout*/
|
18620 |
a[12] === "bubble"
|
18621 |
), (!y || S[0] & /*value, render_markdown*/
|
18622 |
+
513) && rt(i, "message-markdown-disabled", !/*render_markdown*/
|
18623 |
a[9]), S[0] & /*rtl, value*/
|
18624 |
33 && An(
|
18625 |
i,
|
|
|
18903 |
}
|
18904 |
return s = p(a), i = f[s] = o[s](a), {
|
18905 |
c() {
|
18906 |
+
n = n0("div"), i.c(), Be(n, "class", "svelte-kqrm1b"), rt(
|
18907 |
n,
|
18908 |
"thought",
|
18909 |
+
/*thought_index*/
|
|
|
18910 |
a[43] > 0
|
18911 |
);
|
18912 |
},
|
|
|
18917 |
let x = s;
|
18918 |
s = p(b), s === x ? f[s].p(b, y) : (A0(), Me(f[x], 1, 1, () => {
|
18919 |
f[x] = null;
|
18920 |
+
}), v0(), i = f[s], i ? i.p(b, y) : (i = f[s] = o[s](b), i.c()), _e(i, 1), i.m(n, null));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18921 |
},
|
18922 |
i(b) {
|
18923 |
u || (_e(i), u = !0);
|
|
|
19329 |
}
|
19330 |
return ~(u = q(a)) && (o = B[u] = C[u](W(a, u))), {
|
19331 |
c() {
|
19332 |
+
x && x.c(), n = si(), s = n0("div"), i = n0("div"), o && o.c(), Be(i, "class", "message-wrap svelte-kqrm1b"), rt(
|
19333 |
i,
|
19334 |
"bubble-gap",
|
19335 |
/*layout*/
|
|
|
19337 |
), Be(s, "class", f = Oa(
|
19338 |
/*layout*/
|
19339 |
a[12] === "bubble" ? "bubble-wrap" : "panel-wrap"
|
19340 |
+
) + " svelte-kqrm1b"), Be(s, "role", "log"), Be(s, "aria-label", "chatbot conversation"), Be(s, "aria-live", "polite"), rt(
|
19341 |
s,
|
19342 |
"placeholder-container",
|
19343 |
/*value*/
|
|
|
19360 |
u = q(j), u === U ? ~u && B[u].p(W(j, u), G) : (o && (A0(), Me(B[U], 1, 1, () => {
|
19361 |
B[U] = null;
|
19362 |
}), v0()), ~u ? (o = B[u], o ? o.p(W(j, u), G) : (o = B[u] = C[u](W(j, u)), o.c()), _e(o, 1), o.m(i, null)) : o = null), (!p || G[0] & /*layout*/
|
19363 |
+
4096) && rt(
|
19364 |
i,
|
19365 |
"bubble-gap",
|
19366 |
/*layout*/
|
|
|
19370 |
/*layout*/
|
19371 |
j[12] === "bubble" ? "bubble-wrap" : "panel-wrap"
|
19372 |
) + " svelte-kqrm1b")) && Be(s, "class", f), (!p || G[0] & /*layout, value*/
|
19373 |
+
4097) && rt(
|
19374 |
s,
|
19375 |
"placeholder-container",
|
19376 |
/*value*/
|
|
|
19394 |
}
|
19395 |
function cd(a) {
|
19396 |
const n = [];
|
19397 |
+
let s = [], i = null;
|
19398 |
+
for (const u of a)
|
19399 |
+
u.role === i ? s.push(u) : (s.length > 0 && n.push(s), s = [u], i = u.role);
|
19400 |
return s.length > 0 && n.push(s), n;
|
19401 |
}
|
19402 |
function hd(a, n, s) {
|
src/backend/gradio_agentchatbot/utils.py
CHANGED
@@ -13,7 +13,6 @@ class ThoughtMetadata(GradioModel):
|
|
13 |
|
14 |
class Message(GradioModel):
|
15 |
role: Literal["user", "assistant"]
|
16 |
-
thought: bool = False
|
17 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
18 |
|
19 |
|
|
|
13 |
|
14 |
class Message(GradioModel):
|
15 |
role: Literal["user", "assistant"]
|
|
|
16 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
17 |
|
18 |
|
src/demo/app.py
CHANGED
@@ -37,6 +37,7 @@ def interact_with_agent(prompt, messages):
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Tabs():
|
39 |
with gr.Tab("Demo"):
|
|
|
40 |
chatbot = AgentChatbot(
|
41 |
label="Agent",
|
42 |
avatar_images=[
|
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Tabs():
|
39 |
with gr.Tab("Demo"):
|
40 |
+
gr.Markdown("# Chat with an LLM Agent 🤖 and see its thoughts 💭")
|
41 |
chatbot = AgentChatbot(
|
42 |
label="Agent",
|
43 |
avatar_images=[
|
src/demo/docs.md
CHANGED
@@ -69,7 +69,7 @@ if __name__ == "__main__":
|
|
69 |
|
70 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
71 |
|
72 |
-
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how
|
73 |
|
74 |
```python
|
75 |
class ThoughtMetadata(GradioModel):
|
@@ -80,14 +80,12 @@ class ThoughtMetadata(GradioModel):
|
|
80 |
class ChatMessage(GradioModel):
|
81 |
role: Literal["user", "assistant"]
|
82 |
content: str
|
83 |
-
thought: bool = False
|
84 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
85 |
|
86 |
|
87 |
class ChatFileMessage(GradioModel):
|
88 |
role: Literal["user", "assistant"]
|
89 |
file: FileData
|
90 |
-
thought: bool = False
|
91 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
92 |
alt_text: Optional[str] = None
|
93 |
```
|
@@ -101,12 +99,20 @@ def chat_echo(prompt: str, messages: List[ChatMessage | ChatFileMessage]) -> Lis
|
|
101 |
return messages
|
102 |
```
|
103 |
|
104 |
-
### Why a different data format?
|
105 |
|
106 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
107 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
108 |
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
### Why are pydantic data classes required?
|
111 |
|
112 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
|
|
69 |
|
70 |
The `AgentChatbot` is similar to the core `Gradio` `Chatbot` but the key difference is in the expected data format of the `value` property.
|
71 |
|
72 |
+
Instead of a list of tuples, each of which can be either a string or tuple, the value is a list of message instances. Each message can be either a `ChatMessage` or a `ChatFileMessage`. These are pydantic classes that are compatible with the OpenAI [message format](https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages). This is how they are defined:
|
73 |
|
74 |
```python
|
75 |
class ThoughtMetadata(GradioModel):
|
|
|
80 |
class ChatMessage(GradioModel):
|
81 |
role: Literal["user", "assistant"]
|
82 |
content: str
|
|
|
83 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
84 |
|
85 |
|
86 |
class ChatFileMessage(GradioModel):
|
87 |
role: Literal["user", "assistant"]
|
88 |
file: FileData
|
|
|
89 |
thought_metadata: ThoughtMetadata = Field(default_factory=ThoughtMetadata)
|
90 |
alt_text: Optional[str] = None
|
91 |
```
|
|
|
99 |
return messages
|
100 |
```
|
101 |
|
102 |
+
### Why a different data format than Gradio core?
|
103 |
|
104 |
The OpenAI data format is the standard format for representing LLM conversations and most API providers have adopted it.
|
105 |
By using a compliant data format, it should be easier to use `AgentChatbot` with multiple API providers and libraries.
|
106 |
|
107 |
|
108 |
+
### What is `thought_metadata` field for?
|
109 |
+
|
110 |
+
You can use this to add additional information data about the current thought, like the names of the tool used.
|
111 |
+
If the `thought_metadata.tool_name` field is not `None`, the message `content` will be displayed in a collapsible tool modal. See below:
|
112 |
+
|
113 |
+
![Tool Modal](https://gradio-builds.s3.amazonaws.com/demo-files/tool_modal.gif)
|
114 |
+
|
115 |
+
|
116 |
### Why are pydantic data classes required?
|
117 |
|
118 |
It should improve developer experience since your editor will auto-complete the required fields and use smart autocomplete for the `role` class. You will also get an error message if your data does not conform to the data format.
|
src/demo/requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
gradio_agentchatbot
|
2 |
-
|
3 |
langchain
|
|
|
4 |
sentence-transformers
|
5 |
faiss-cpu
|
6 |
serpapi
|
|
|
1 |
+
gradio_agentchatbot==0.0.2
|
2 |
+
git+https://github.com/huggingface/transformers.git#egg=transformers[agents]
|
3 |
langchain
|
4 |
+
langchain-community
|
5 |
sentence-transformers
|
6 |
faiss-cpu
|
7 |
serpapi
|
src/frontend/shared/ChatBot.svelte
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
import { Image } from "@gradio/image/shared";
|
10 |
import { Video } from "@gradio/video/shared";
|
11 |
import type { SelectData, LikeData } from "@gradio/utils";
|
12 |
-
import type { ChatMessage, ChatFileMessage, Message } from "../types";
|
13 |
import { MarkdownCode as Markdown } from "@gradio/markdown";
|
14 |
import { FileData } from "@gradio/client";
|
15 |
import Copy from "./Copy.svelte";
|
@@ -135,18 +135,19 @@
|
|
135 |
}
|
136 |
|
137 |
function groupMessages(messages: (ChatMessage | ChatFileMessage)[]): (ChatMessage | ChatFileMessage)[][] {
|
138 |
-
const groupedMessages: (
|
139 |
-
let currentGroup: (
|
|
|
140 |
|
141 |
for (const message of messages) {
|
142 |
-
if (message.
|
143 |
-
|
144 |
} else {
|
145 |
if (currentGroup.length > 0) {
|
146 |
groupedMessages.push(currentGroup);
|
147 |
-
currentGroup = [];
|
148 |
}
|
149 |
-
|
|
|
150 |
}
|
151 |
}
|
152 |
|
@@ -155,7 +156,7 @@
|
|
155 |
}
|
156 |
|
157 |
return groupedMessages;
|
158 |
-
}
|
159 |
|
160 |
</script>
|
161 |
|
@@ -222,7 +223,7 @@
|
|
222 |
{#each messages as message, thought_index}
|
223 |
|
224 |
{#if !isFileMessage(message)}
|
225 |
-
<div class:thought={
|
226 |
{#if message.thought_metadata.tool_name}
|
227 |
<ToolMessage
|
228 |
title={`Used tool ${message.thought_metadata.tool_name}`}
|
|
|
9 |
import { Image } from "@gradio/image/shared";
|
10 |
import { Video } from "@gradio/video/shared";
|
11 |
import type { SelectData, LikeData } from "@gradio/utils";
|
12 |
+
import type { ChatMessage, ChatFileMessage, Message, MessageRole } from "../types";
|
13 |
import { MarkdownCode as Markdown } from "@gradio/markdown";
|
14 |
import { FileData } from "@gradio/client";
|
15 |
import Copy from "./Copy.svelte";
|
|
|
135 |
}
|
136 |
|
137 |
function groupMessages(messages: (ChatMessage | ChatFileMessage)[]): (ChatMessage | ChatFileMessage)[][] {
|
138 |
+
const groupedMessages: (ChatMessage | ChatFileMessage)[][] = [];
|
139 |
+
let currentGroup: (ChatMessage | ChatFileMessage)[] = [];
|
140 |
+
let currentRole: MessageRole | null = null;
|
141 |
|
142 |
for (const message of messages) {
|
143 |
+
if (message.role === currentRole) {
|
144 |
+
currentGroup.push(message);
|
145 |
} else {
|
146 |
if (currentGroup.length > 0) {
|
147 |
groupedMessages.push(currentGroup);
|
|
|
148 |
}
|
149 |
+
currentGroup = [message];
|
150 |
+
currentRole = message.role;
|
151 |
}
|
152 |
}
|
153 |
|
|
|
156 |
}
|
157 |
|
158 |
return groupedMessages;
|
159 |
+
}
|
160 |
|
161 |
</script>
|
162 |
|
|
|
223 |
{#each messages as message, thought_index}
|
224 |
|
225 |
{#if !isFileMessage(message)}
|
226 |
+
<div class:thought={thought_index > 0}>
|
227 |
{#if message.thought_metadata.tool_name}
|
228 |
<ToolMessage
|
229 |
title={`Used tool ${message.thought_metadata.tool_name}`}
|
src/frontend/types.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import type { FileData } from "@gradio/client";
|
2 |
|
3 |
-
type MessageRole = "system" | "user"
|
4 |
|
5 |
|
6 |
export interface ThoughtMetadata {
|
@@ -11,7 +11,6 @@ export interface ThoughtMetadata {
|
|
11 |
export interface Message {
|
12 |
role: MessageRole;
|
13 |
thought_metadata: ThoughtMetadata;
|
14 |
-
thought: boolean;
|
15 |
}
|
16 |
|
17 |
export interface ChatMessage extends Message {
|
|
|
1 |
import type { FileData } from "@gradio/client";
|
2 |
|
3 |
+
export type MessageRole = "system" | "user";
|
4 |
|
5 |
|
6 |
export interface ThoughtMetadata {
|
|
|
11 |
export interface Message {
|
12 |
role: MessageRole;
|
13 |
thought_metadata: ThoughtMetadata;
|
|
|
14 |
}
|
15 |
|
16 |
export interface ChatMessage extends Message {
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_agentchatbot"
|
11 |
-
version = "0.0.
|
12 |
description = "Chat with agents 🤖 and see the tools they use 🛠️"
|
13 |
readme = "README.md"
|
14 |
license = "apache-2.0"
|
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_agentchatbot"
|
11 |
+
version = "0.0.2"
|
12 |
description = "Chat with agents 🤖 and see the tools they use 🛠️"
|
13 |
readme = "README.md"
|
14 |
license = "apache-2.0"
|