Display streaming response that may have Latex

I am using streaming with streamlit as below

                for response in client.chat.completions.create(
                    model=st.session_state["openai_model"],
                    messages=messages_so_far,
                    stream=True,
                ):
                    full_response += (response.choices[0].delta.content or "")
                    message_placeholder.markdown(full_response + "β–Œ")

The issue is my response may contain math equations which are likely to be latex. How do I show the display as equations ? Right now, it shows as

[ \rho \left( \frac{\partial \mathbf{u}}{\partial t} + \mathbf{u} \cdot \nabla \mathbf{u} \right) = -\nabla p + \mu \nabla^2 \mathbf{u} + \mathbf{f} ]
1 Like

Hi @kris_k

Can you encapsulate the output to be displayed using st.latex()

More info in the Docs: