How to export st.markdown() content as it is shown on the app

:rotating_light: Before clicking “Create Topic”, please make sure your post includes the following information (otherwise, the post will be locked). :rotating_light:

  1. Are you running your app locally or is it deployed?
  2. If your app is deployed:
    a. Is it deployed on Community Cloud or another hosting platform?
    b. Share the link to the public deployed app.
  3. Share the link to your app’s public GitHub repository (including a requirements file).
  4. Share the full text of the error message (not a screenshot).
  5. Share the Streamlit and Python versions.

Hi @Faizan_Saifi

Could you provide additional context to what you’re aiming to achieve? Thanks!

I developed chat app using streamlit, for some query the LLM generates table. So, I want to extract that table in a PDF in the same format as it is shown in the app. So, can you please tell me how can I do that in streamlit.

Hi @Faizan_Saifi

Typically, when creating a chatbot, you would store LLM generated responses in the session state variable namely st.session_state.messages

You can tap into the contents stored in this session state variable and export its content as a Markdown or HTML file. To achieve this you can look into using a package such as Markdown (Markdown · PyPI).

See this tutorial for some ideas on using the Markdown library:

Hope this helps!

Thanks @dataprofessor

I will check it. Thanks for helping

1 Like