Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -249,13 +249,16 @@ for i, message in enumerate(st.session_state.chat_history):
|
|
249 |
if message["role"] == "user":
|
250 |
st.markdown(f"<div class='user-msg'><strong>You:</strong> {message['content']}</div>", unsafe_allow_html=True)
|
251 |
else:
|
252 |
-
|
253 |
-
|
254 |
-
🔊 Speak
|
255 |
-
</button>
|
256 |
-
"""
|
257 |
st.markdown(
|
258 |
-
f"<div class='assistant-msg'
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
unsafe_allow_html=True
|
260 |
)
|
261 |
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
249 |
if message["role"] == "user":
|
250 |
st.markdown(f"<div class='user-msg'><strong>You:</strong> {message['content']}</div>", unsafe_allow_html=True)
|
251 |
else:
|
252 |
+
# Fix: Use JavaScript data attribute instead of trying to escape in f-string
|
253 |
+
content_for_id = f"msg-{i}"
|
|
|
|
|
|
|
254 |
st.markdown(
|
255 |
+
f"""<div class='assistant-msg'>
|
256 |
+
<strong>HAL:</strong> {message['content']}
|
257 |
+
<button onclick="speakText(document.getElementById('{content_for_id}').textContent)" class="speak-button">
|
258 |
+
🔊 Speak
|
259 |
+
</button>
|
260 |
+
<span id="{content_for_id}" style="display:none">{message['content']}</span>
|
261 |
+
</div>""",
|
262 |
unsafe_allow_html=True
|
263 |
)
|
264 |
st.markdown("</div>", unsafe_allow_html=True)
|