chkla commited on
Commit
1d9d8c2
β€’
1 Parent(s): 5bfc4e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -50
app.py CHANGED
@@ -94,53 +94,49 @@ def render_prompt_card(prompt):
94
 
95
  card_container.container().write("---")
96
 
97
- def main():
98
- if "selected_prompt_id" not in st.session_state:
99
- st.session_state.selected_prompt_id = None
100
-
101
- st.title("🏷️ Annotation PromptCards Archive")
102
- st.write("Welcome to the Prompt Archive! Click on the 'View details' button on each prompt card to see more information about the annotation prompt.")
103
- st.write("---")
104
-
105
- prompts = load_prompts()
106
- language_list = list(set([prompt['language'] for prompt in prompts]))
107
- task_list = list(set([prompt['task'] for prompt in prompts]))
108
-
109
- st.sidebar.header("**Annotation PromptCards Archive**")
110
-
111
- st.sidebar.write("A collection of prompts for annotation tasks in NLP. This is a work in progress. Please contribute your prompts via GitHub [[Upload]](https://github.com/chkla/PromptCards).")
112
-
113
- # add a link to the GitHub repository
114
- st.sidebar.write("---")
115
- st.sidebar.write(f"**Total number of prompts:** {len(prompts)}")
116
- st.sidebar.write("---")
117
-
118
- st.sidebar.header("πŸ§‘πŸ½β€πŸš€ Explore:")
119
- search = st.sidebar.text_input("Search by title")
120
- language_filter = st.sidebar.selectbox("Filter by Language", ["All"] + language_list)
121
- task_filter = st.sidebar.selectbox("Filter by Task", ["All"] + task_list)
122
-
123
- if st.sidebar.button("Back to list"):
124
- st.session_state.selected_prompt_id = None
125
- st.experimental_rerun()
126
-
127
- if st.session_state.selected_prompt_id is None:
128
- filtered_prompts = [
129
- prompt for prompt in prompts
130
- if (search.lower() in prompt['title'].lower() or not search)
131
- and (prompt['language'] == language_filter or language_filter == "All")
132
- and (prompt['task'] == task_filter or task_filter == "All")
133
- ]
134
-
135
- for prompt in filtered_prompts:
136
- render_prompt_card(prompt)
137
- else:
138
- prompt = next((p for p in prompts if p["id"] == st.session_state.selected_prompt_id), None)
139
- if prompt:
140
- render_prompt_details(prompt)
141
-
142
- st.sidebar.write("---")
143
- st.sidebar.write("Made with ❀️ and πŸ€– by [Chkla](https://chkla.github.io/).")
144
-
145
- if __name__ == "__main__":
146
- main()
 
94
 
95
  card_container.container().write("---")
96
 
97
+ if "selected_prompt_id" not in st.session_state:
98
+ st.session_state.selected_prompt_id = None
99
+
100
+ st.title("🏷️ Annotation PromptCards Archive")
101
+ st.write("Welcome to the Prompt Archive! Click on the 'View details' button on each prompt card to see more information about the annotation prompt.")
102
+ st.write("---")
103
+
104
+ prompts = load_prompts()
105
+ language_list = list(set([prompt['language'] for prompt in prompts]))
106
+ task_list = list(set([prompt['task'] for prompt in prompts]))
107
+
108
+ st.sidebar.header("**Annotation PromptCards Archive**")
109
+
110
+ st.sidebar.write("A collection of prompts for annotation tasks in NLP. This is a work in progress. Please contribute your prompts via GitHub [[Upload]](https://github.com/chkla/PromptCards).")
111
+
112
+ # add a link to the GitHub repository
113
+ st.sidebar.write("---")
114
+ st.sidebar.write(f"**Total number of prompts:** {len(prompts)}")
115
+ st.sidebar.write("---")
116
+
117
+ st.sidebar.header("πŸ§‘πŸ½β€πŸš€ Explore:")
118
+ search = st.sidebar.text_input("Search by title")
119
+ language_filter = st.sidebar.selectbox("Filter by Language", ["All"] + language_list)
120
+ task_filter = st.sidebar.selectbox("Filter by Task", ["All"] + task_list)
121
+
122
+ if st.sidebar.button("Back to list"):
123
+ st.session_state.selected_prompt_id = None
124
+ st.experimental_rerun()
125
+
126
+ if st.session_state.selected_prompt_id is None:
127
+ filtered_prompts = [
128
+ prompt for prompt in prompts
129
+ if (search.lower() in prompt['title'].lower() or not search)
130
+ and (prompt['language'] == language_filter or language_filter == "All")
131
+ and (prompt['task'] == task_filter or task_filter == "All")
132
+ ]
133
+
134
+ for prompt in filtered_prompts:
135
+ render_prompt_card(prompt)
136
+ else:
137
+ prompt = next((p for p in prompts if p["id"] == st.session_state.selected_prompt_id), None)
138
+ if prompt:
139
+ render_prompt_details(prompt)
140
+
141
+ st.sidebar.write("---")
142
+ st.sidebar.write("Made with ❀️ and πŸ€– by [Chkla](https://chkla.github.io/).")