Spaces:
Running
Running
gulixin0922
commited on
Commit
•
b3f697c
1
Parent(s):
9da9834
Update conversation.py
Browse files- conversation.py +21 -3
conversation.py
CHANGED
@@ -203,12 +203,29 @@ class Conversation:
|
|
203 |
# f'<img src="data:image/png;base64,{img_b64_str}" alt="{alt_str}" />'
|
204 |
# )
|
205 |
img_str_list.append(img_str)
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
if msg["role"] == self.USER:
|
208 |
-
msg_str = " ".join(img_str_list) +
|
209 |
ret.append([msg_str, None])
|
210 |
else:
|
211 |
-
msg_str =
|
212 |
ret[-1][-1] = msg_str
|
213 |
return ret
|
214 |
|
@@ -304,3 +321,4 @@ class Conversation:
|
|
304 |
return filename
|
305 |
|
306 |
|
|
|
|
203 |
# f'<img src="data:image/png;base64,{img_b64_str}" alt="{alt_str}" />'
|
204 |
# )
|
205 |
img_str_list.append(img_str)
|
206 |
+
|
207 |
+
if ('\[' in msg["content"] and '\]' in msg["content"]) or ('\(' in msg["content"] and '\)' in msg["content"]):
|
208 |
+
# 行内公式 or 行间公式
|
209 |
+
content = msg["content"].replace('\[', '$$').replace('\]', '$$').replace('\(', '$$').replace('\)', '$$')
|
210 |
+
content = content.split('$$')
|
211 |
+
for i in range(len(content)):
|
212 |
+
if i % 2:
|
213 |
+
content[i] = content[i].strip()
|
214 |
+
content = '$$'.join(content)
|
215 |
+
print('content:', content)
|
216 |
+
# content = (
|
217 |
+
# r"<span>" + content + r"</span>"
|
218 |
+
# r"<script type='text/javascript'>"
|
219 |
+
# r"MathJax.typesetPromise();"
|
220 |
+
# r"</script>"
|
221 |
+
# )
|
222 |
+
else:
|
223 |
+
content = msg["content"]
|
224 |
if msg["role"] == self.USER:
|
225 |
+
msg_str = " ".join(img_str_list) + content
|
226 |
ret.append([msg_str, None])
|
227 |
else:
|
228 |
+
msg_str = content + " ".join(img_str_list)
|
229 |
ret[-1][-1] = msg_str
|
230 |
return ret
|
231 |
|
|
|
321 |
return filename
|
322 |
|
323 |
|
324 |
+
|