Spaces:
Running
Running
Update app.py
Browse files
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.
|
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
|
763 |
|
764 |
4. **View Chat History:**
|
765 |
-
- All your queries and the corresponding AI responses are displayed in the chat history
|
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
|
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 |
-
#
|
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()
|