Spaces:
Runtime error
Runtime error
add lang
Browse files
app.py
CHANGED
|
@@ -27,18 +27,26 @@ def generation_markup_format(text):
|
|
| 27 |
return f"<font color={PROMPT_COLOR}>{text}</pre></font>"
|
| 28 |
|
| 29 |
|
| 30 |
-
ds = load_dataset("
|
| 31 |
ds = ds["train"]
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
col_1, col_2 = st.columns(2)
|
| 36 |
with col_1:
|
| 37 |
st.markdown("<h1 style='text-align: center'>Prompt</h1>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
chosen_prompt = st.selectbox("Choose a prompt", possible_prompts)
|
| 39 |
st.markdown(safe_text(chosen_prompt), unsafe_allow_html=True)
|
| 40 |
|
| 41 |
-
sub_ds =
|
| 42 |
lambda exs: [prompt == chosen_prompt for prompt in exs["prompt"]], batched=True
|
| 43 |
)
|
| 44 |
|
|
|
|
| 27 |
return f"<font color={PROMPT_COLOR}>{text}</pre></font>"
|
| 28 |
|
| 29 |
|
| 30 |
+
ds = load_dataset("/home/lucile_huggingface_co/repos/bloom-generations/bloom-generations.py", use_auth_token=HF_API_TOKEN)
|
| 31 |
ds = ds["train"]
|
| 32 |
|
| 33 |
+
possible_langs = ds.unique("lang")
|
| 34 |
|
| 35 |
col_1, col_2 = st.columns(2)
|
| 36 |
with col_1:
|
| 37 |
st.markdown("<h1 style='text-align: center'>Prompt</h1>", unsafe_allow_html=True)
|
| 38 |
+
chosen_lang = st.selectbox("Choose a lang", possible_langs + ["all"])
|
| 39 |
+
if chosen_lang == "all":
|
| 40 |
+
ds_lang = ds
|
| 41 |
+
else:
|
| 42 |
+
ds_lang = ds.filter(
|
| 43 |
+
lambda exs: [lang == chosen_lang for lang in exs["lang"]], batched=True
|
| 44 |
+
)
|
| 45 |
+
possible_prompts = ds_lang.unique("prompt")
|
| 46 |
chosen_prompt = st.selectbox("Choose a prompt", possible_prompts)
|
| 47 |
st.markdown(safe_text(chosen_prompt), unsafe_allow_html=True)
|
| 48 |
|
| 49 |
+
sub_ds = ds_lang.filter(
|
| 50 |
lambda exs: [prompt == chosen_prompt for prompt in exs["prompt"]], batched=True
|
| 51 |
)
|
| 52 |
|