siddhartharya commited on
Commit
ad34ca4
Β·
verified Β·
1 Parent(s): 70eb2ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -155,7 +155,6 @@ def get_page_metadata(soup):
155
  metadata['title'] = og_title.get('content', '').strip()
156
 
157
  return metadata
158
-
159
  def generate_summary_and_assign_category(bookmark):
160
  """
161
  Generate a concise summary and assign a category using a single LLM call.
@@ -415,7 +414,7 @@ def display_bookmarks():
415
  card_style = "border: 2px solid red;"
416
  text_style = "color: white;"
417
  elif bookmark.get('slow_link'):
418
- status = "⏳ Slow Response"
419
  card_style = "border: 2px solid orange;"
420
  text_style = "color: white;"
421
  else:
@@ -691,7 +690,6 @@ Provide a concise and helpful response.
691
  logger.error(error_message, exc_info=True)
692
  chat_history.append({"role": "assistant", "content": error_message})
693
  return chat_history
694
-
695
  def build_app():
696
  """
697
  Build and launch the Gradio app.
@@ -753,16 +751,16 @@ Navigate through the tabs to explore each feature in detail.
753
  ### πŸ€– **How to Interact:**
754
 
755
  1. **Enter Your Query:**
756
- - In the **"✍️ Ask about your bookmarks"** textbox, type your question or keyword related to your bookmarks. For example, "Do I have any bookmarks about GenerativeAI?"
757
 
758
  2. **Submit Your Query:**
759
  - Click the **"πŸ“¨ Send"** button to submit your query.
760
 
761
  3. **Receive AI-Driven Responses:**
762
- - SmartMarks will analyze your query and provide relevant bookmarks that match your request, making it easier to find specific links without manual searching.
763
 
764
  4. **View Chat History:**
765
- - All your queries and the corresponding AI responses are displayed in the chat history for your reference.
766
  """)
767
 
768
  chatbot = gr.Chatbot(label="πŸ’¬ Chat with SmartMarks", type='messages')
@@ -781,7 +779,8 @@ Navigate through the tabs to explore each feature in detail.
781
  # Manage Bookmarks Tab
782
  with gr.Tab("Manage Bookmarks"):
783
  gr.Markdown("""
784
- ## πŸ› οΈ **Manage Bookmarks
 
785
  ### πŸ—‚οΈ **Features:**
786
 
787
  1. **View Bookmarks:**
@@ -800,7 +799,6 @@ Navigate through the tabs to explore each feature in detail.
800
 
801
  5. **Export Bookmarks:**
802
  - Click the **"πŸ’Ύ Export"** button to download your updated bookmarks as an HTML file.
803
- - This file can be uploaded back to your browser to reflect the changes made within SmartMarks.
804
 
805
  6. **Refresh Bookmarks:**
806
  - Click the **"πŸ”„ Refresh Bookmarks"** button to ensure the latest state is reflected in the display.
@@ -808,7 +806,7 @@ Navigate through the tabs to explore each feature in detail.
808
 
809
  manage_output = gr.Textbox(label="πŸ”„ Status", interactive=False)
810
 
811
- # Move bookmark_selector definition here
812
  bookmark_selector = gr.CheckboxGroup(
813
  label="βœ… Select Bookmarks",
814
  choices=[]
@@ -829,7 +827,7 @@ Navigate through the tabs to explore each feature in detail.
829
 
830
  download_link = gr.File(label="πŸ“₯ Download Exported Bookmarks")
831
 
832
- # Update process_button to use the bookmark_selector in Manage tab
833
  process_button.click(
834
  process_uploaded_file,
835
  inputs=[upload, state_bookmarks],
@@ -871,4 +869,5 @@ Navigate through the tabs to explore each feature in detail.
871
  logger.error(f"Error building the app: {e}", exc_info=True)
872
  print(f"Error building the app: {e}")
873
 
874
- if __name__ == "__main__":
 
 
155
  metadata['title'] = og_title.get('content', '').strip()
156
 
157
  return metadata
 
158
  def generate_summary_and_assign_category(bookmark):
159
  """
160
  Generate a concise summary and assign a category using a single LLM call.
 
414
  card_style = "border: 2px solid red;"
415
  text_style = "color: white;"
416
  elif bookmark.get('slow_link'):
417
+ status = "⏳ Slow Response"
418
  card_style = "border: 2px solid orange;"
419
  text_style = "color: white;"
420
  else:
 
690
  logger.error(error_message, exc_info=True)
691
  chat_history.append({"role": "assistant", "content": error_message})
692
  return chat_history
 
693
  def build_app():
694
  """
695
  Build and launch the Gradio app.
 
751
  ### πŸ€– **How to Interact:**
752
 
753
  1. **Enter Your Query:**
754
+ - In the **"✍️ Ask about your bookmarks"** textbox, type your question or keyword related to your bookmarks.
755
 
756
  2. **Submit Your Query:**
757
  - Click the **"πŸ“¨ Send"** button to submit your query.
758
 
759
  3. **Receive AI-Driven Responses:**
760
+ - SmartMarks will analyze your query and provide relevant bookmarks that match your request.
761
 
762
  4. **View Chat History:**
763
+ - All your queries and the corresponding AI responses are displayed in the chat history.
764
  """)
765
 
766
  chatbot = gr.Chatbot(label="πŸ’¬ Chat with SmartMarks", type='messages')
 
779
  # Manage Bookmarks Tab
780
  with gr.Tab("Manage Bookmarks"):
781
  gr.Markdown("""
782
+ ## πŸ› οΈ **Manage Bookmarks**
783
+
784
  ### πŸ—‚οΈ **Features:**
785
 
786
  1. **View Bookmarks:**
 
799
 
800
  5. **Export Bookmarks:**
801
  - Click the **"πŸ’Ύ Export"** button to download your updated bookmarks as an HTML file.
 
802
 
803
  6. **Refresh Bookmarks:**
804
  - Click the **"πŸ”„ Refresh Bookmarks"** button to ensure the latest state is reflected in the display.
 
806
 
807
  manage_output = gr.Textbox(label="πŸ”„ Status", interactive=False)
808
 
809
+ # Move bookmark_selector here
810
  bookmark_selector = gr.CheckboxGroup(
811
  label="βœ… Select Bookmarks",
812
  choices=[]
 
827
 
828
  download_link = gr.File(label="πŸ“₯ Download Exported Bookmarks")
829
 
830
+ # Connect all the button actions
831
  process_button.click(
832
  process_uploaded_file,
833
  inputs=[upload, state_bookmarks],
 
869
  logger.error(f"Error building the app: {e}", exc_info=True)
870
  print(f"Error building the app: {e}")
871
 
872
+ if __name__ == "__main__":
873
+ build_app()