userisanillusion commited on
Commit
c92b527
·
verified ·
1 Parent(s): 4a82ede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import re
3
  import numpy as np
@@ -12,12 +13,7 @@ from typing import List, Dict, Any, Tuple, Optional, Union, Generator
12
  from dataclasses import dataclass
13
  import gradio as gr
14
 
15
- # Install dependencies in the app.py file for Spaces
16
- os.system("pip install -q pymupdf langchain langchain_community sentence-transformers faiss-cpu huggingface_hub")
17
- os.system("pip install -q llama-cpp-python transformers rank_bm25 nltk")
18
- os.system("pip install -q git+https://github.com/chroma-core/chroma.git")
19
-
20
- # Import dependencies after installation
21
  import fitz # PyMuPDF
22
  from langchain.text_splitter import RecursiveCharacterTextSplitter
23
  from langchain_community.vectorstores import FAISS
@@ -29,6 +25,13 @@ from nltk.tokenize import word_tokenize
29
  from nltk.corpus import stopwords
30
  from huggingface_hub import hf_hub_download
31
 
 
 
 
 
 
 
 
32
  # Setup directories for Spaces
33
  os.makedirs("pdfs", exist_ok=True)
34
  os.makedirs("models", exist_ok=True)
 
1
+
2
  import os
3
  import re
4
  import numpy as np
 
13
  from dataclasses import dataclass
14
  import gradio as gr
15
 
16
+ # Import dependencies (no need for pip install commands)
 
 
 
 
 
17
  import fitz # PyMuPDF
18
  from langchain.text_splitter import RecursiveCharacterTextSplitter
19
  from langchain_community.vectorstores import FAISS
 
25
  from nltk.corpus import stopwords
26
  from huggingface_hub import hf_hub_download
27
 
28
+ # Download nltk resources
29
+ try:
30
+ nltk.download('punkt', quiet=True)
31
+ nltk.download('stopwords', quiet=True)
32
+ except:
33
+ print("Failed to download NLTK resources, continuing without them")
34
+
35
  # Setup directories for Spaces
36
  os.makedirs("pdfs", exist_ok=True)
37
  os.makedirs("models", exist_ok=True)