Spaces:
Running
Running
# app.py | |
import gradio as gr | |
from bs4 import BeautifulSoup | |
import requests | |
from transformers import pipeline | |
from sentence_transformers import SentenceTransformer | |
import faiss | |
import numpy as np | |
# Initialize models and variables | |
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
embedding_model = SentenceTransformer('all-MiniLM-L6-v2') | |
index = None | |
bookmarks = [] | |
fetch_cache = {} | |
# Helper functions as defined above... | |
def parse_bookmarks(file_content): | |
# [Code from Step 4.1] | |
def fetch_url_info(bookmark): | |
# [Code from Step 4.2] | |
def generate_summary(bookmark): | |
# [Code from Step 4.3] | |
def vectorize_and_index(bookmarks): | |
# [Code from Step 4.4] | |
def process_uploaded_file(file): | |
# [Code from Step 5.1] | |
def chatbot_response(user_query): | |
# [Code from Step 5.2] | |
def display_bookmarks(): | |
# [Code from Step 5.3] | |
def edit_bookmark(index, new_title, new_url): | |
# [Code from Step 5.3] | |
def delete_bookmark(index): | |
# [Code from Step 5.3] | |
def build_app(): | |
# [Code from Step 6] | |
if __name__ == "__main__": | |
build_app() | |