Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -169,72 +169,72 @@ if st.button('Submit'):
|
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
|
|
|
|
| 190 |
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
topics_list = [slide_title]
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
test_list = read_from_file("retrieved_docs.json")
|
| 205 |
-
train_list = read_from_file("retrieved_docs_train.json")
|
| 206 |
-
organize_out =
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
#
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
st.
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
train_list = read_from_file("retrieved_docs_train.json")
|
| 224 |
-
organize_out = read_from_file("organized_docs.json")
|
| 225 |
-
gen_summary_dict = get_retrieved_results("gpt4o", 1, "fixed", train_list, test_list, False, organize_out)
|
| 226 |
-
for i in range(len(gen_summary_dict)):
|
| 227 |
-
# highlighted_summary = highlight_sentences(gen_summary_dict[i], test_list[i]['abstract'])
|
| 228 |
-
slides_list.append(get_slide(topics_list[i], gen_summary_dict[i]))
|
| 229 |
-
# generate_list.append(.format(topics_list[i], gen_summary_dict[i]))
|
| 230 |
-
st.markdown(f"## {topics_list[i]}")
|
| 231 |
-
st.markdown(f"{gen_summary_dict[i]}")
|
| 232 |
-
# st.markdown(highlighted_summary, unsafe_allow_html=True)
|
| 233 |
-
st.header("Generated Narrative")
|
| 234 |
-
for i in range(len(slides_list)):
|
| 235 |
-
st.markdown("---")
|
| 236 |
-
st.markdown(slides_list[i])
|
| 237 |
-
st.markdown("---")
|
| 238 |
-
# if st.session_state.summarize_clicked:
|
| 239 |
-
# if st.button("Narrative"):
|
| 240 |
-
# st.session_state.narrative_clicked = True
|
|
|
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
+
if st.session_state.submit_clicked:
|
| 173 |
+
if st.button('Retrieve'):
|
| 174 |
+
if 'organize_clicked' not in st.session_state:
|
| 175 |
+
st.session_state.organize_clicked = False
|
| 176 |
+
st.session_state.retrieve_clicked = True
|
| 177 |
+
retrieved_out = get_retrieved_results("gpt4o", 0, "fixed", list_2, list_1)
|
| 178 |
+
write_to_file("retrieved_docs.json", retrieved_out)
|
| 179 |
+
retrieved_out_train = get_retrieved_results("gpt4o", 0, "fixed", list_1, list_2)
|
| 180 |
+
write_to_file("retrieved_docs_train.json", retrieved_out_train)
|
| 181 |
+
|
| 182 |
+
for ret_item in retrieved_out:
|
| 183 |
+
for key in ret_item['ref_abstract']:
|
| 184 |
+
# inp_doc_list.append(item['ref_abstract'][key])
|
| 185 |
+
retrieved_doc_list.append(ret_item['ref_abstract'][key]['abstract'])
|
| 186 |
|
| 187 |
+
# Step 2: Lowercase the documents
|
| 188 |
+
|
| 189 |
+
st.header('Retrieved Documents')
|
| 190 |
+
|
| 191 |
+
for i in range(len(section_names)):
|
| 192 |
+
ui_retrieved_doc_list.append(st.text_area(retrieve_prompt_template.format(inp_keys_list[i], ref_doc_indices[i], section_names[i], document_name), value=retrieved_doc_list[i]))
|
| 193 |
+
if st.session_state.retrieve_clicked:
|
| 194 |
+
if st.button('Organize'):
|
| 195 |
+
if 'summarize_clicked' not in st.session_state:
|
| 196 |
+
st.session_state.summarize_clicked = False
|
| 197 |
+
st.session_state.organize_clicked = True
|
| 198 |
+
st.header("Organization of the documents in the narrative")
|
| 199 |
+
topics_list = [slide_title]
|
| 200 |
|
| 201 |
+
organize_list = []
|
| 202 |
+
ui_organize_list = []
|
| 203 |
|
| 204 |
+
test_list = read_from_file("retrieved_docs.json")
|
| 205 |
+
train_list = read_from_file("retrieved_docs_train.json")
|
| 206 |
+
organize_out = get_retrieved_results("gpt4o", 1, "fixed", train_list, test_list, True)
|
| 207 |
+
for i in range(len(organize_out)):
|
| 208 |
+
organize_list.append(organize_out[i])
|
| 209 |
+
ui_organize_list.append(st.text_area("Section: " + topics_list[i], value=organize_out[i]))
|
| 210 |
+
write_to_file("organized_docs.json", organize_out)
|
| 211 |
+
|
| 212 |
+
if st.session_state.organize_clicked:
|
| 213 |
+
if st.button("Summarize"):
|
| 214 |
+
# if 'narrative_clicked' not in st.session_state:
|
| 215 |
+
# st.session_state.narrative_clicked = False
|
| 216 |
+
st.session_state.summarize_clicked = True
|
| 217 |
+
st.header("Intent-based multi-document summary")
|
| 218 |
topics_list = [slide_title]
|
| 219 |
+
generate_list = []
|
| 220 |
+
ui_generate_list = []
|
| 221 |
+
slides_list = []
|
|
|
|
| 222 |
test_list = read_from_file("retrieved_docs.json")
|
| 223 |
+
train_list = read_from_file("retrieved_docs_train.json")
|
| 224 |
+
organize_out = read_from_file("organized_docs.json")
|
| 225 |
+
gen_summary_dict = get_retrieved_results("gpt4o", 1, "fixed", train_list, test_list, False, organize_out)
|
| 226 |
+
for i in range(len(gen_summary_dict)):
|
| 227 |
+
# highlighted_summary = highlight_sentences(gen_summary_dict[i], test_list[i]['abstract'])
|
| 228 |
+
slides_list.append(get_slide(topics_list[i], gen_summary_dict[i]))
|
| 229 |
+
# generate_list.append(.format(topics_list[i], gen_summary_dict[i]))
|
| 230 |
+
st.markdown(f"## {topics_list[i]}")
|
| 231 |
+
st.markdown(f"{gen_summary_dict[i]}")
|
| 232 |
+
# st.markdown(highlighted_summary, unsafe_allow_html=True)
|
| 233 |
+
st.header("Generated Narrative")
|
| 234 |
+
for i in range(len(slides_list)):
|
| 235 |
+
st.markdown("---")
|
| 236 |
+
st.markdown(slides_list[i])
|
| 237 |
+
st.markdown("---")
|
| 238 |
+
# if st.session_state.summarize_clicked:
|
| 239 |
+
# if st.button("Narrative"):
|
| 240 |
+
# st.session_state.narrative_clicked = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|