Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
from datasets import load_dataset
|
| 5 |
import random
|
|
|
|
| 6 |
# Load math datasets for sample problems
|
| 7 |
fw = load_dataset("HuggingFaceFW/fineweb-edu", name="sample-10BT", split="train", streaming=True)
|
| 8 |
ds = load_dataset("HuggingFaceH4/ultrachat_200k", streaming=True)
|
|
@@ -62,6 +63,13 @@ def respond(
|
|
| 62 |
temperature,
|
| 63 |
top_p,
|
| 64 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Show initial thinking message
|
| 66 |
yield "🤔 Thinking for the suitable answer..."
|
| 67 |
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
from datasets import load_dataset
|
| 5 |
import random
|
| 6 |
+
import re
|
| 7 |
# Load math datasets for sample problems
|
| 8 |
fw = load_dataset("HuggingFaceFW/fineweb-edu", name="sample-10BT", split="train", streaming=True)
|
| 9 |
ds = load_dataset("HuggingFaceH4/ultrachat_200k", streaming=True)
|
|
|
|
| 63 |
temperature,
|
| 64 |
top_p,
|
| 65 |
):
|
| 66 |
+
def render_latex(text):
|
| 67 |
+
# Wrap inline math properly
|
| 68 |
+
text = re.sub(r'\$(.*?)\$', r'$$\1$$', text) # Display mode
|
| 69 |
+
return text
|
| 70 |
+
|
| 71 |
+
yield render_latex(response)
|
| 72 |
+
|
| 73 |
# Show initial thinking message
|
| 74 |
yield "🤔 Thinking for the suitable answer..."
|
| 75 |
|