Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,8 +34,22 @@ retriever_tokenizer = AutoTokenizer.from_pretrained(retriever_model_name)
|
|
34 |
from langchain_community.vectorstores import FAISS
|
35 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
36 |
|
|
|
37 |
hf_embeddings = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Function to extract text from a PDF file
|
41 |
def extract_text_from_pdf(pdf_data):
|
|
|
34 |
from langchain_community.vectorstores import FAISS
|
35 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
36 |
|
37 |
+
# Initialize Hugging Face embeddings
|
38 |
hf_embeddings = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
|
39 |
+
|
40 |
+
# Dummy implementations for index, docstore, and index_to_docstore_id
|
41 |
+
# Replace with actual implementations or configurations as per LangChain documentation
|
42 |
+
index = None
|
43 |
+
docstore = None
|
44 |
+
index_to_docstore_id = None
|
45 |
+
|
46 |
+
# Initialize FAISS index with required parameters
|
47 |
+
faiss_index = FAISS(
|
48 |
+
embedding_function=hf_embeddings,
|
49 |
+
index=index,
|
50 |
+
docstore=docstore,
|
51 |
+
index_to_docstore_id=index_to_docstore_id
|
52 |
+
)
|
53 |
|
54 |
# Function to extract text from a PDF file
|
55 |
def extract_text_from_pdf(pdf_data):
|