Spaces:
Runtime error
Runtime error
Download app.py from Gagan202004/Assignment3: direct link, hf CLI and curl.
- Browser
- Download file 884 Bytes
-
https://huggingface.co/spaces/Gagan202004/Assignment3/resolve/main/app.py
- Command line
-
hf download hf://spaces/Gagan202004/Assignment3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Gagan202004/Assignment3/resolve/main/app.py
884 Bytes
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| from typing import List, Tuple | |
| import fitz # PyMuPDF | |
| from sentence_transformers import SentenceTransformer, util | |
| import numpy as np | |
| import faiss | |
| client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") | |
| """ | |
| class MyApp: | |
| def __init__(self) -> None: | |
| self.documents = [] | |
| self.embeddings = None | |
| self.index = None | |
| self.load_pdf("Mypdf") | |
| self.build_vector_db() | |
| def load_pdf(self, file:///C:/Users/gagan/OneDrive/Desktop/Mypdf.pdf: str) -> None: | |
| doc = fitz.open(file:///C:/Users/gagan/OneDrive/Desktop/Mypdf.pdf) | |
| self.documents = [] | |
| for page_num in range(len(doc)): | |
| page = doc[page_num] | |
| text = page.get_text() | |
| self.documents.append({"page": page_num + 1, "content": text}) | |
| print("PDF processed successfully!") |