react-markdown with streaming support for streamlit webapp.
- streaming rendering of markdown text
- support for latex math, mermaid diagrams, code highlighting
- support for tables, images, links
Have a try at https://streaming-markdown.streamlit.app/
pip install streamlit-markdown
static content:
from streamlit_markdown import st_markdown
markdown_text = "$ y = f(x)$"
st_markdown(markdown_text)
streaming content:
from streamlit_markdown import st_streaming_markdown
markdown_text = "$ y = f(x)$"
def token_stream():
for token in markdown_text:
yeild token
st_streaming_markdown(token_stream, key="token_stream") # key must be set to prevent re-rendering
combined streaming content:
from streamlit_markdown import st_streaming_markdown
markdown_text = "$ y = f(x)$"
def token_stream():
import random
for token in markdown_text:
if random.rand() > 0.5:
yeild token
else:
def callable_token():
return token
yeild callable_token
st_streaming_markdown(token_stream, key="token_stream") # key must be set to prevent re-rendering
run example:
streamlit run example.py
- nodejs >= 18.x
- yarn >= 1.22.x
- poetry >= 1.2.x
- python >= 3.8.x
./build.sh
poetry publish
This project is licensed under the MIT License - see the LICENSE file for details