Spaces:
Runtime error
Runtime error
from datasets import load_dataset | |
import streamlit as st | |
HF_API_TOKEN = st.secrets["HF_API_TOKEN"] | |
PROMPT_COLOR = "#CA437E" | |
ds = load_dataset("SaulLu/bloom-generations", use_auth_token=HF_API_TOKEN) | |
ds = ds["train"] | |
def safe_text(text): | |
text = text.replace("\n", "<br>") | |
return f"<pre>{text}</pre>" | |
def prompt_markup_format(text): | |
return f'<*font color="black">{text}</*font>' | |
def generation_markup_format(text): | |
return f"<font color={PROMPT_COLOR}>{text}</pre></font>" | |
index_sample = st.number_input("Index of the chosen example", min_value=0, max_value=len(ds) - 1, value=0, step=1) | |
sample = ds[index_sample] | |
markdown_text = f"{prompt_markup_format(sample['prompt'])}{generation_markup_format(sample['generation'])}" | |
markdown_text = f"{safe_text(sample['prompt'])}{generation_markup_format(safe_text(sample['generation']))}" | |
st.markdown(markdown_text, unsafe_allow_html=True) | |