Spaces:
Runtime error
Runtime error
update app
Browse files
app.py
CHANGED
|
@@ -4,10 +4,6 @@ import streamlit as st
|
|
| 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>"
|
|
@@ -20,10 +16,20 @@ def prompt_markup_format(text):
|
|
| 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(
|
| 25 |
-
sample =
|
| 26 |
-
markdown_text =
|
| 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)
|
|
|
|
|
|
|
|
|
| 4 |
HF_API_TOKEN = st.secrets["HF_API_TOKEN"]
|
| 5 |
PROMPT_COLOR = "#CA437E"
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def safe_text(text):
|
| 8 |
text = text.replace("\n", "<br>")
|
| 9 |
return f"<pre>{text}</pre>"
|
|
|
|
| 16 |
def generation_markup_format(text):
|
| 17 |
return f"<font color={PROMPT_COLOR}>{text}</pre></font>"
|
| 18 |
|
| 19 |
+
ds = load_dataset("SaulLu/bloom-generations", use_auth_token=HF_API_TOKEN)
|
| 20 |
+
ds = ds["train"]
|
| 21 |
+
|
| 22 |
+
possible_prompts = ds.unique("prompt")
|
| 23 |
+
chosen_prompt = st.selectbox("Chose a prompt", possible_prompts)
|
| 24 |
+
st.markdown(safe_text(chosen_prompt), unsafe_allow_html=True)
|
| 25 |
+
|
| 26 |
+
sub_ds = ds.filter(lambda exs:[prompt==chosen_prompt for prompt in exs["prompt"]], batched=True)
|
| 27 |
+
|
| 28 |
|
| 29 |
+
index_sample = st.number_input("Index of the chosen example", min_value=0, max_value=len(sub_ds) - 1, value=0, step=1)
|
| 30 |
+
sample = sub_ds[index_sample]
|
| 31 |
+
markdown_text = generation_markup_format(safe_text(sample['generation']))
|
|
|
|
| 32 |
|
| 33 |
st.markdown(markdown_text, unsafe_allow_html=True)
|
| 34 |
+
config = {key:value for key, value in sample.items() if key not in ["prompt", "generation"]}
|
| 35 |
+
config
|