mihirjadhav commited on
Commit
0c4d515
·
verified ·
1 Parent(s): 0a8885b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
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
- # embeddings = OpenAIEmbeddings()
35
- embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
36
- vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
37
- return vectorstore
 
 
 
 
 
 
 
 
 
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):