Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -275,29 +275,29 @@ def process_uploaded_file(file):
|
|
275 |
logger.info("Processing uploaded file")
|
276 |
if file is None:
|
277 |
logger.warning("No file uploaded")
|
278 |
-
return "Please upload a bookmarks HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
279 |
try:
|
280 |
file_content = file.decode('utf-8')
|
281 |
except UnicodeDecodeError as e:
|
282 |
logger.error(f"Error decoding the file: {e}")
|
283 |
-
return "Error decoding the file. Please ensure it's a valid HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
284 |
|
285 |
try:
|
286 |
bookmarks = parse_bookmarks(file_content)
|
287 |
except Exception as e:
|
288 |
logger.error(f"Error parsing bookmarks: {e}")
|
289 |
-
return "Error parsing the bookmarks HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
290 |
|
291 |
if not bookmarks:
|
292 |
logger.warning("No bookmarks found in the uploaded file")
|
293 |
-
return "No bookmarks found in the uploaded file.", '', gr.update(choices=[]), display_bookmarks()
|
294 |
|
295 |
# Asynchronously fetch bookmark info
|
296 |
try:
|
297 |
asyncio.run(process_bookmarks_async(bookmarks))
|
298 |
except Exception as e:
|
299 |
logger.error(f"Error processing bookmarks asynchronously: {e}")
|
300 |
-
return "Error processing bookmarks.", '', gr.update(choices=[]), display_bookmarks()
|
301 |
|
302 |
# Generate summaries and assign categories
|
303 |
for bookmark in bookmarks:
|
@@ -308,7 +308,7 @@ def process_uploaded_file(file):
|
|
308 |
faiss_index, embeddings = vectorize_and_index(bookmarks)
|
309 |
except Exception as e:
|
310 |
logger.error(f"Error building FAISS index: {e}")
|
311 |
-
return "Error building search index.", '', gr.update(choices=[]), display_bookmarks()
|
312 |
|
313 |
message = f"β
Successfully processed {len(bookmarks)} bookmarks."
|
314 |
logger.info(message)
|
@@ -453,7 +453,7 @@ Please identify the most relevant bookmarks that match the user's query. Provide
|
|
453 |
def build_app():
|
454 |
try:
|
455 |
logger.info("Building Gradio app")
|
456 |
-
with gr.Blocks(css="""
|
457 |
.card {
|
458 |
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
459 |
transition: 0.3s;
|
@@ -489,11 +489,11 @@ def build_app():
|
|
489 |
### π **Steps to Upload and Process:**
|
490 |
|
491 |
1. **π½ Upload Bookmarks File:**
|
492 |
-
- Click on the **"Upload Bookmarks HTML File"** button.
|
493 |
- Select your browser's exported bookmarks HTML file from your device.
|
494 |
|
495 |
2. **βοΈ Process Bookmarks:**
|
496 |
-
- After uploading, click on the **"Process Bookmarks"** button.
|
497 |
- SmartMarks will parse your bookmarks, fetch additional information, generate summaries, and categorize each link based on predefined categories.
|
498 |
|
499 |
3. **π View Processed Bookmarks:**
|
@@ -523,10 +523,10 @@ def build_app():
|
|
523 |
### π€ **How to Interact:**
|
524 |
|
525 |
1. **βοΈ Enter Your Query:**
|
526 |
-
- 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?"
|
527 |
|
528 |
2. **π¨ Submit Your Query:**
|
529 |
-
- Click the **"Send"** button to submit your query.
|
530 |
|
531 |
3. **π Receive AI-Driven Responses:**
|
532 |
- SmartMarks will analyze your query and provide relevant bookmarks that match your request, making it easier to find specific links without manual searching.
|
@@ -556,15 +556,15 @@ def build_app():
|
|
556 |
- Use the checkboxes next to each bookmark to select one, multiple, or all bookmarks you wish to manage.
|
557 |
|
558 |
3. **ποΈ Delete Selected Bookmarks:**
|
559 |
-
- After selecting the desired bookmarks, click the **"Delete Selected Bookmarks"** button to remove them from your list.
|
560 |
|
561 |
4. **βοΈ Edit Categories:**
|
562 |
- Select the bookmarks you want to re-categorize.
|
563 |
-
- Choose a new category from the dropdown menu labeled **"New Category"**.
|
564 |
-
- Click the **"Edit Category of Selected Bookmarks"** button to update their categories.
|
565 |
|
566 |
5. **πΎ Export Bookmarks:**
|
567 |
-
- Click the **"Export Bookmarks"** button to download your updated bookmarks as an HTML file.
|
568 |
- This file can be uploaded back to your browser to reflect the changes made within SmartMarks.
|
569 |
""")
|
570 |
|
|
|
275 |
logger.info("Processing uploaded file")
|
276 |
if file is None:
|
277 |
logger.warning("No file uploaded")
|
278 |
+
return "β οΈ Please upload a bookmarks HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
279 |
try:
|
280 |
file_content = file.decode('utf-8')
|
281 |
except UnicodeDecodeError as e:
|
282 |
logger.error(f"Error decoding the file: {e}")
|
283 |
+
return "β οΈ Error decoding the file. Please ensure it's a valid HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
284 |
|
285 |
try:
|
286 |
bookmarks = parse_bookmarks(file_content)
|
287 |
except Exception as e:
|
288 |
logger.error(f"Error parsing bookmarks: {e}")
|
289 |
+
return "β οΈ Error parsing the bookmarks HTML file.", '', gr.update(choices=[]), display_bookmarks()
|
290 |
|
291 |
if not bookmarks:
|
292 |
logger.warning("No bookmarks found in the uploaded file")
|
293 |
+
return "β οΈ No bookmarks found in the uploaded file.", '', gr.update(choices=[]), display_bookmarks()
|
294 |
|
295 |
# Asynchronously fetch bookmark info
|
296 |
try:
|
297 |
asyncio.run(process_bookmarks_async(bookmarks))
|
298 |
except Exception as e:
|
299 |
logger.error(f"Error processing bookmarks asynchronously: {e}")
|
300 |
+
return "β οΈ Error processing bookmarks.", '', gr.update(choices=[]), display_bookmarks()
|
301 |
|
302 |
# Generate summaries and assign categories
|
303 |
for bookmark in bookmarks:
|
|
|
308 |
faiss_index, embeddings = vectorize_and_index(bookmarks)
|
309 |
except Exception as e:
|
310 |
logger.error(f"Error building FAISS index: {e}")
|
311 |
+
return "β οΈ Error building search index.", '', gr.update(choices=[]), display_bookmarks()
|
312 |
|
313 |
message = f"β
Successfully processed {len(bookmarks)} bookmarks."
|
314 |
logger.info(message)
|
|
|
453 |
def build_app():
|
454 |
try:
|
455 |
logger.info("Building Gradio app")
|
456 |
+
with gr.Blocks(theme=gr.themes.Default(), css="""
|
457 |
.card {
|
458 |
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
459 |
transition: 0.3s;
|
|
|
489 |
### π **Steps to Upload and Process:**
|
490 |
|
491 |
1. **π½ Upload Bookmarks File:**
|
492 |
+
- Click on the **"π Upload Bookmarks HTML File"** button.
|
493 |
- Select your browser's exported bookmarks HTML file from your device.
|
494 |
|
495 |
2. **βοΈ Process Bookmarks:**
|
496 |
+
- After uploading, click on the **"βοΈ Process Bookmarks"** button.
|
497 |
- SmartMarks will parse your bookmarks, fetch additional information, generate summaries, and categorize each link based on predefined categories.
|
498 |
|
499 |
3. **π View Processed Bookmarks:**
|
|
|
523 |
### π€ **How to Interact:**
|
524 |
|
525 |
1. **βοΈ Enter Your Query:**
|
526 |
+
- 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?"
|
527 |
|
528 |
2. **π¨ Submit Your Query:**
|
529 |
+
- Click the **"π¨ Send"** button to submit your query.
|
530 |
|
531 |
3. **π Receive AI-Driven Responses:**
|
532 |
- SmartMarks will analyze your query and provide relevant bookmarks that match your request, making it easier to find specific links without manual searching.
|
|
|
556 |
- Use the checkboxes next to each bookmark to select one, multiple, or all bookmarks you wish to manage.
|
557 |
|
558 |
3. **ποΈ Delete Selected Bookmarks:**
|
559 |
+
- After selecting the desired bookmarks, click the **"ποΈ Delete Selected Bookmarks"** button to remove them from your list.
|
560 |
|
561 |
4. **βοΈ Edit Categories:**
|
562 |
- Select the bookmarks you want to re-categorize.
|
563 |
+
- Choose a new category from the dropdown menu labeled **"π New Category"**.
|
564 |
+
- Click the **"βοΈ Edit Category of Selected Bookmarks"** button to update their categories.
|
565 |
|
566 |
5. **πΎ Export Bookmarks:**
|
567 |
+
- Click the **"πΎ Export Bookmarks"** button to download your updated bookmarks as an HTML file.
|
568 |
- This file can be uploaded back to your browser to reflect the changes made within SmartMarks.
|
569 |
""")
|
570 |
|