loubnabnl HF staff commited on
Commit
c6c5724
1 Parent(s): b19b634

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -39,7 +39,8 @@ ds = load_data(educational_topic)
39
 
40
  with col_2:
41
  category_types = ['afaik', 'defined_by_llm', 'defined_by_llm_under_afaik']
42
- selected_category_type = st.selectbox("Select Category Type", category_types)
 
43
  with col_3:
44
  categories = get_categories_by_type(ds, selected_category_type)
45
  selected_category = st.selectbox("Select Category", categories)
@@ -47,8 +48,19 @@ with col_3:
47
  selected_cluster = ds.filter(lambda x: x['category'] == selected_category)
48
 
49
  # Select sample index
50
- n_samples = len(selected_cluster["examples"])
51
- index_example = st.number_input(f"Index of a sample: 0 - {n_samples}", min_value=0, max_value=n_samples-1, value=0, step=1)
 
 
 
 
52
 
53
- sample = selected_cluster["examples"][index_example]
54
- st.markdown(sample)
 
 
 
 
 
 
 
 
39
 
40
  with col_2:
41
  category_types = ['afaik', 'defined_by_llm', 'defined_by_llm_under_afaik']
42
+ default_index = 0 if educational_topic == "Yes" else 1
43
+ selected_category_type = st.selectbox("Select Category Type", category_types, index=default_index)
44
  with col_3:
45
  categories = get_categories_by_type(ds, selected_category_type)
46
  selected_category = st.selectbox("Select Category", categories)
 
48
  selected_cluster = ds.filter(lambda x: x['category'] == selected_category)
49
 
50
  # Select sample index
51
+ print(f"selected_cluster is {selected_cluster}")
52
+ n_samples = len(selected_cluster)
53
+ if n_samples > 0:
54
+ col_1, col_2 = st.columns(2)
55
+ with col_1:
56
+ index_cluster = st.number_input(f"Found {len(selected_cluster)} clusters, choose one", min_value=0, max_value=len(selected_cluster)-1, value=0, step=1)
57
 
58
+ files = selected_cluster[index_cluster]["examples"]
59
+
60
+ with col_2:
61
+ index_example = st.number_input(f"Found {len(files)} files in the cluster, choose one", min_value=0, max_value=len(files)-1, value=0, step=1)
62
+
63
+ sample = files[index_example]
64
+ st.markdown(sample)
65
+ else:
66
+ st