Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,7 +122,7 @@ def render_message(history):
|
|
| 122 |
<div id="chatbox-container" class="chatbox" style="height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;">
|
| 123 |
<div id="messages" style="display: block; margin-bottom: 10px;">"""
|
| 124 |
|
| 125 |
-
seen_messages = set()
|
| 126 |
|
| 127 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
| 128 |
if user_message and ("user", user_message) not in seen_messages:
|
|
@@ -145,10 +145,24 @@ def render_message(history):
|
|
| 145 |
|
| 146 |
mathjax_script = """
|
| 147 |
<script type="text/javascript">
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
</script>
|
|
|
|
|
|
|
| 152 |
"""
|
| 153 |
return messages_html + mathjax_script
|
| 154 |
|
|
@@ -175,12 +189,10 @@ with gr.Blocks(css=css) as demo:
|
|
| 175 |
|
| 176 |
with gr.Column(visible=False) as chat_view:
|
| 177 |
gr.HTML("""
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
gr.Markdown("## P-MSQ Chat Interface")
|
| 185 |
chatbot_output = gr.HTML(elem_id="chatbox-container")
|
| 186 |
gr.Markdown(elem_id="chatbox-container")
|
|
@@ -239,7 +251,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 239 |
msg_input.submit(
|
| 240 |
user_interaction,
|
| 241 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
| 242 |
-
outputs=[chatbot_output, history_state, msg_input]
|
| 243 |
)
|
| 244 |
|
| 245 |
send_btn.click(
|
|
|
|
| 122 |
<div id="chatbox-container" class="chatbox" style="height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;">
|
| 123 |
<div id="messages" style="display: block; margin-bottom: 10px;">"""
|
| 124 |
|
| 125 |
+
seen_messages = set()
|
| 126 |
|
| 127 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
| 128 |
if user_message and ("user", user_message) not in seen_messages:
|
|
|
|
| 145 |
|
| 146 |
mathjax_script = """
|
| 147 |
<script type="text/javascript">
|
| 148 |
+
MathJax = {
|
| 149 |
+
tex: {
|
| 150 |
+
inlineMath: [['\\(', '\\)']],
|
| 151 |
+
displayMath: [
|
| 152 |
+
['\\[', '\\]'],
|
| 153 |
+
['\\begin{equation}', '\\end{equation}'],
|
| 154 |
+
['\\begin{align}', '\\end{align}'],
|
| 155 |
+
['\\begin{alignat}', '\\end{alignat}'],
|
| 156 |
+
['\\begin{gather}', '\\end{gather}'],
|
| 157 |
+
['\\begin{CD}', '\\end{CD}']
|
| 158 |
+
],
|
| 159 |
+
processEscapes: true
|
| 160 |
+
},
|
| 161 |
+
svg: { fontCache: 'global' }
|
| 162 |
+
};
|
| 163 |
</script>
|
| 164 |
+
<script type="text/javascript" async
|
| 165 |
+
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.js"></script>
|
| 166 |
"""
|
| 167 |
return messages_html + mathjax_script
|
| 168 |
|
|
|
|
| 189 |
|
| 190 |
with gr.Column(visible=False) as chat_view:
|
| 191 |
gr.HTML("""
|
| 192 |
+
<script type="text/javascript" id="MathJax-script" async
|
| 193 |
+
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js">
|
| 194 |
+
</script>
|
| 195 |
+
""")
|
|
|
|
|
|
|
| 196 |
gr.Markdown("## P-MSQ Chat Interface")
|
| 197 |
chatbot_output = gr.HTML(elem_id="chatbox-container")
|
| 198 |
gr.Markdown(elem_id="chatbox-container")
|
|
|
|
| 251 |
msg_input.submit(
|
| 252 |
user_interaction,
|
| 253 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
| 254 |
+
outputs=[chatbot_output, history_state, msg_input],
|
| 255 |
)
|
| 256 |
|
| 257 |
send_btn.click(
|