awacke1 commited on
Commit
6c7eed9
·
verified ·
1 Parent(s): 2156133

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -711,8 +711,7 @@ def main():
711
  if st.session_state.current_index < total_docs - 1:
712
  st.session_state.current_index += 1
713
  st.rerun()
714
-
715
-
716
  elif selected_view == 'Show as Code Editor':
717
  Label = '# 💻 Code editor view'
718
  st.markdown(Label)
@@ -753,25 +752,30 @@ def main():
753
  if st.button("🗑️ Delete", key=f'delete_button_{st.session_state.current_index}'):
754
  try:
755
  current_doc = json.loads(doc_str)
 
 
 
 
 
756
  options = {
757
  'enableCrossPartitionQuery': True,
758
- 'partitionKey': '/Id'
759
  }
760
- response = container.delete_item(
761
- item=current_doc['id'],
762
- partition_key=current_doc['id'],
763
- enable_cross_partition_query=True
764
- )
 
 
765
  if response:
766
  st.success(f"Document {current_doc['id']} deleted successfully.")
767
  if st.session_state.current_index > 0:
768
  st.session_state.current_index -= 1
769
  st.rerun()
770
  except Exception as e:
771
- st.error(f"Error deleting document: {str(e)}")
772
-
773
-
774
-
775
 
776
  elif selected_view == 'Show as Edit, Save, Run AI':
777
  Label = '# ✏️ Edit and save view - Edit with wisdom, save with precision'
 
711
  if st.session_state.current_index < total_docs - 1:
712
  st.session_state.current_index += 1
713
  st.rerun()
714
+
 
715
  elif selected_view == 'Show as Code Editor':
716
  Label = '# 💻 Code editor view'
717
  st.markdown(Label)
 
752
  if st.button("🗑️ Delete", key=f'delete_button_{st.session_state.current_index}'):
753
  try:
754
  current_doc = json.loads(doc_str)
755
+
756
+ # Get client directly from container's client property
757
+ client = container._client
758
+
759
+ # Set up delete options
760
  options = {
761
  'enableCrossPartitionQuery': True,
762
+ 'partitionKey': current_doc['id']
763
  }
764
+
765
+ # Construct document link
766
+ doc_link = f"dbs/{DATABASE_NAME}/colls/{CONTAINER_NAME}/docs/{current_doc['id']}"
767
+
768
+ # Delete using client directly
769
+ response = client.DeleteItem(doc_link, options)
770
+
771
  if response:
772
  st.success(f"Document {current_doc['id']} deleted successfully.")
773
  if st.session_state.current_index > 0:
774
  st.session_state.current_index -= 1
775
  st.rerun()
776
  except Exception as e:
777
+ st.error(f"Error deleting document: {str(e)}")
778
+
 
 
779
 
780
  elif selected_view == 'Show as Edit, Save, Run AI':
781
  Label = '# ✏️ Edit and save view - Edit with wisdom, save with precision'