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