Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import tempfile
|
|
| 5 |
import uuid
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
from langchain_community.vectorstores import FAISS
|
| 8 |
-
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
| 9 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 10 |
import fitz # PyMuPDF
|
| 11 |
import base64
|
|
@@ -38,7 +38,8 @@ except Exception as e:
|
|
| 38 |
)
|
| 39 |
except Exception as e:
|
| 40 |
print(f"Warning: Failed to load fallback embeddings model: {e}")
|
| 41 |
-
embeddings
|
|
|
|
| 42 |
|
| 43 |
# Directory to store FAISS indexes
|
| 44 |
FAISS_INDEX_DIR = "faiss_indexes_tech"
|
|
@@ -631,10 +632,9 @@ gr.HTML("""
|
|
| 631 |
</div>
|
| 632 |
""")
|
| 633 |
|
| 634 |
-
# Launch the app
|
| 635 |
if __name__ == "__main__":
|
| 636 |
-
demo
|
| 637 |
-
demo.launch()
|
| 638 |
|
| 639 |
# Add new helper functions
|
| 640 |
def detect_language(extension):
|
|
|
|
| 5 |
import uuid
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
from langchain_community.vectorstores import FAISS
|
| 8 |
+
from langchain_community.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings
|
| 9 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 10 |
import fitz # PyMuPDF
|
| 11 |
import base64
|
|
|
|
| 38 |
)
|
| 39 |
except Exception as e:
|
| 40 |
print(f"Warning: Failed to load fallback embeddings model: {e}")
|
| 41 |
+
# Use a simpler embeddings model as a fallback
|
| 42 |
+
embeddings = HuggingFaceEmbeddings()
|
| 43 |
|
| 44 |
# Directory to store FAISS indexes
|
| 45 |
FAISS_INDEX_DIR = "faiss_indexes_tech"
|
|
|
|
| 632 |
</div>
|
| 633 |
""")
|
| 634 |
|
| 635 |
+
# Launch the app directly
|
| 636 |
if __name__ == "__main__":
|
| 637 |
+
demo.launch()
|
|
|
|
| 638 |
|
| 639 |
# Add new helper functions
|
| 640 |
def detect_language(extension):
|