Spaces:
Runtime error
Runtime error
add app
Browse files- app.py +29 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
HF_API_TOKEN = st.secrets["HF_API_TOKEN"]
|
| 5 |
+
PROMPT_COLOR = "#CA437E"
|
| 6 |
+
|
| 7 |
+
ds = load_dataset("SaulLu/bloom-generations", use_auth_token=HF_API_TOKEN)
|
| 8 |
+
ds = ds["train"]
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def safe_text(text):
|
| 12 |
+
text = text.replace("\n", "<br>")
|
| 13 |
+
return f"<pre>{text}</pre>"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def prompt_markup_format(text):
|
| 17 |
+
return f'<*font color="black">{text}</*font>'
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def generation_markup_format(text):
|
| 21 |
+
return f"<font color={PROMPT_COLOR}>{text}</pre></font>"
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
index_sample = st.number_input("Index of the chosen example", min_value=0, max_value=len(ds) - 1, value=0, step=1)
|
| 25 |
+
sample = ds[index_sample]
|
| 26 |
+
markdown_text = f"{prompt_markup_format(sample['prompt'])}{generation_markup_format(sample['generation'])}"
|
| 27 |
+
markdown_text = f"{safe_text(sample['prompt'])}{generation_markup_format(safe_text(sample['generation']))}"
|
| 28 |
+
|
| 29 |
+
st.markdown(markdown_text, unsafe_allow_html=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
datasets
|