Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from dotenv import load_dotenv
|
3 |
from PyPDF2 import PdfReader
|
@@ -30,11 +32,20 @@ def get_text_chunks(text):
|
|
30 |
return chunks
|
31 |
|
32 |
|
33 |
-
def get_vectorstore(text_chunks):
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
def get_conversation_chain(vectorstore):
|
|
|
1 |
+
import tempfile
|
2 |
+
import os
|
3 |
import streamlit as st
|
4 |
from dotenv import load_dotenv
|
5 |
from PyPDF2 import PdfReader
|
|
|
32 |
return chunks
|
33 |
|
34 |
|
35 |
+
# def get_vectorstore(text_chunks):
|
36 |
+
# # embeddings = OpenAIEmbeddings()
|
37 |
+
# embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
|
38 |
+
# vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
39 |
+
# return vectorstore
|
40 |
+
|
41 |
+
def get_vectorstore(text_chunks):
|
42 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
43 |
+
# Temporarily set the cache directory
|
44 |
+
os.environ["TRANSFORMERS_CACHE"] = tmp_dir
|
45 |
+
|
46 |
+
embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
|
47 |
+
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
48 |
+
return vectorstore
|
49 |
|
50 |
|
51 |
def get_conversation_chain(vectorstore):
|