awacke1 commited on
Commit
0f9876c
·
verified ·
1 Parent(s): b0ec638

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -23
app.py CHANGED
@@ -610,7 +610,7 @@ def main():
610
 
611
  if documents_to_display:
612
  # 🎨 View options - "Different strokes for different folks"
613
- view_options = ['Show as Markdown', 'Show as Code Editor', 'Show as Edit, Save, Run AI', 'Clone Document', 'New Record']
614
  selected_view = st.sidebar.selectbox("Select Viewer/Editor", view_options, index=2)
615
 
616
 
@@ -708,11 +708,9 @@ def main():
708
  st.error(f"Error deleting document: {str(e)}")
709
 
710
 
711
- elif selected_view == 'Show as Edit, Save, Run AI':
712
- Label = '# ✏️ Edit and save view - Edit with wisdom, save with precision'
713
- st.markdown(Label)
714
- st.markdown("#### Edit the document fields below:")
715
-
716
  num_cols = len(documents_to_display)
717
  cols = st.columns(num_cols)
718
 
@@ -729,29 +727,13 @@ def main():
729
  editable_doc = doc.copy()
730
  editable_doc.pop('name', None)
731
 
732
-
733
  doc_str = st.text_area("Document Content (in JSON format)",
734
  value=json.dumps(editable_doc, indent=2),
735
  height=300,
736
  key=f'doc_str_{idx}')
737
 
738
  # 💾🤖 Save and AI operations
739
- col_save, col_ai, col_delete = st.columns(3)
740
-
741
- with col_save:
742
- if st.button("💾 Save Changes", key=f'save_button_{idx}'):
743
- try:
744
- updated_doc = json.loads(doc_str)
745
- updated_doc['id'] = editable_id
746
- success, message = update_record(container, updated_doc)
747
- if success:
748
- st.success(f"Document {updated_doc['id']} saved successfully.")
749
- st.session_state.selected_document_id = updated_doc['id']
750
- st.rerun()
751
- else:
752
- st.error(message)
753
- except json.JSONDecodeError as e:
754
- st.error(f"Invalid JSON: {str(e)} 🚫")
755
 
756
  with col_ai:
757
  if st.button("🤖 Run AI", key=f'run_with_ai_button_{idx}'):
 
610
 
611
  if documents_to_display:
612
  # 🎨 View options - "Different strokes for different folks"
613
+ view_options = ['Show as Markdown', 'Show as Code Editor', 'Show as Run AI', 'Clone Document', 'New Record']
614
  selected_view = st.sidebar.selectbox("Select Viewer/Editor", view_options, index=2)
615
 
616
 
 
708
  st.error(f"Error deleting document: {str(e)}")
709
 
710
 
711
+ elif selected_view == 'Show as Run AI':
712
+ Label = '# ✏️ Run AI with wisdom, save with precision'
713
+ st.markdown(Label)
 
 
714
  num_cols = len(documents_to_display)
715
  cols = st.columns(num_cols)
716
 
 
727
  editable_doc = doc.copy()
728
  editable_doc.pop('name', None)
729
 
 
730
  doc_str = st.text_area("Document Content (in JSON format)",
731
  value=json.dumps(editable_doc, indent=2),
732
  height=300,
733
  key=f'doc_str_{idx}')
734
 
735
  # 💾🤖 Save and AI operations
736
+ col_ai, col_delete = st.columns(2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
 
738
  with col_ai:
739
  if st.button("🤖 Run AI", key=f'run_with_ai_button_{idx}'):