Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,7 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
12 |
from langchain_community.embeddings import SentenceTransformerEmbeddings
|
13 |
from groq import Groq
|
14 |
import gradio as gr
|
15 |
-
|
16 |
-
|
17 |
-
# Login to Hugging Face Hub using your API token
|
18 |
-
HUGGINGFACEHUB_API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
19 |
-
login(token=HUGGINGFACEHUB_API_TOKEN)
|
20 |
|
21 |
# Ensure the Tesseract OCR path is set correctly
|
22 |
pytesseract.pytesseract.tesseract_cmd = r'/usr/bin/tesseract'
|
@@ -62,15 +58,16 @@ def compute_cosine_similarity_scores(query, retrieved_docs):
|
|
62 |
return readable_scores
|
63 |
|
64 |
def fetch_files_from_huggingface_space():
|
65 |
-
|
66 |
-
file_names = [f"{i}.docx" for i in range(
|
67 |
|
68 |
file_contents = []
|
69 |
for file_name in file_names:
|
|
|
70 |
try:
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
print(f"Successfully downloaded {file_name}")
|
75 |
except Exception as e:
|
76 |
print(f"Failed to download {file_name}: {e}")
|
@@ -192,4 +189,3 @@ iface = gr.Interface(
|
|
192 |
)
|
193 |
|
194 |
iface.launch()
|
195 |
-
|
|
|
12 |
from langchain_community.embeddings import SentenceTransformerEmbeddings
|
13 |
from groq import Groq
|
14 |
import gradio as gr
|
15 |
+
import requests
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Ensure the Tesseract OCR path is set correctly
|
18 |
pytesseract.pytesseract.tesseract_cmd = r'/usr/bin/tesseract'
|
|
|
58 |
return readable_scores
|
59 |
|
60 |
def fetch_files_from_huggingface_space():
|
61 |
+
base_url = "https://huggingface.co/spaces/Luciferalive/goosev9/blob/main/"
|
62 |
+
file_names = [f"{i}.docx" for i in range(2, 22)]
|
63 |
|
64 |
file_contents = []
|
65 |
for file_name in file_names:
|
66 |
+
file_url = f"{base_url}{file_name}"
|
67 |
try:
|
68 |
+
response = requests.get(file_url)
|
69 |
+
response.raise_for_status()
|
70 |
+
file_contents.append(response.content)
|
71 |
print(f"Successfully downloaded {file_name}")
|
72 |
except Exception as e:
|
73 |
print(f"Failed to download {file_name}: {e}")
|
|
|
189 |
)
|
190 |
|
191 |
iface.launch()
|
|