Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,53 +94,49 @@ def render_prompt_card(prompt):
|
|
| 94 |
|
| 95 |
card_container.container().write("---")
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 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/).")
|
|
|
|
|
|
|
|
|
|
|
|