awacke1 commited on
Commit
605e4db
β€’
1 Parent(s): fa5a711

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -287,22 +287,33 @@ def search_glossary(query):
287
  st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
288
 
289
  # When saving results, pass the container
290
- save_to_cosmos_db(st.session_state.cosmos_container, query, result, result)
291
- save_to_cosmos_db(st.session_state.cosmos_container, query, result2, result2)
292
- save_to_cosmos_db(st.session_state.cosmos_container, query, result3, result3)
293
- save_to_cosmos_db(st.session_state.cosmos_container, query, response2[0], response2[0])
294
- save_to_cosmos_db(st.session_state.cosmos_container, query, response2[1], response2[1])
295
-
296
- # Aggregate hyperlinks and show with emojis
297
- hyperlinks = extract_hyperlinks([response1, response2])
298
- st.markdown("### πŸ”— Aggregated Hyperlinks")
299
- for link in hyperlinks:
300
- st.markdown(f"πŸ”— [{link}]({link})")
301
-
302
- # Show responses in a code format with line numbers
303
- st.markdown("### πŸ“œ Response Outputs with Line Numbers")
304
- st.code(f"Response 1: \n{format_with_line_numbers(response1)}\n\nResponse 2: \n{format_with_line_numbers(response2)}", language="json")
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
 
308
 
 
287
  st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
288
 
289
  # When saving results, pass the container
290
+ try:
291
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result, result)
292
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result2, result2)
293
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result3, result3)
294
+ save_to_cosmos_db(st.session_state.cosmos_container, query, response2[0], response2[0])
295
+ save_to_cosmos_db(st.session_state.cosmos_container, query, response2[1], response2[1])
296
+ except exceptions.CosmosHttpResponseError as e:
297
+ return False, f"HTTP error occurred: {str(e)} 🚨"
298
+ except Exception as e:
299
+ return False, f"An unexpected error occurred: {str(e)} 😱"
300
+
 
 
 
 
301
 
302
+ try:
303
+ # Aggregate hyperlinks and show with emojis
304
+ hyperlinks = extract_hyperlinks([response1, response2])
305
+ st.markdown("### πŸ”— Aggregated Hyperlinks")
306
+ for link in hyperlinks:
307
+ st.markdown(f"πŸ”— [{link}]({link})")
308
+
309
+ # Show responses in a code format with line numbers
310
+ st.markdown("### πŸ“œ Response Outputs with Line Numbers")
311
+ st.code(f"Response 1: \n{format_with_line_numbers(response1)}\n\nResponse 2: \n{format_with_line_numbers(response2)}", language="json")
312
+ except exceptions.CosmosHttpResponseError as e:
313
+ return False, f"HTTP error occurred: {str(e)} 🚨"
314
+ except Exception as e:
315
+ return False, f"An unexpected error occurred: {str(e)} 😱"
316
+
317
 
318
 
319