Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import os
|
|
3 |
import streamlit as st
|
4 |
from PyPDF2 import PdfReader
|
5 |
from langchain.text_splitter import CharacterTextSplitter
|
6 |
-
from langchain.embeddings import
|
7 |
from langchain.vectorstores import FAISS
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from langchain.chains import ConversationalRetrievalChain
|
@@ -29,11 +29,11 @@ def get_text_chunks(text):
|
|
29 |
|
30 |
|
31 |
def get_vectorstore(text_chunks):
|
32 |
-
model = "
|
33 |
encode_kwargs = {
|
34 |
"normalize_embeddings": True
|
35 |
}
|
36 |
-
embeddings =
|
37 |
model_name=model, encode_kwargs=encode_kwargs, model_kwargs={"device": "cpu"}
|
38 |
)
|
39 |
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
@@ -70,7 +70,7 @@ def main():
|
|
70 |
page_icon="π",
|
71 |
)
|
72 |
|
73 |
-
st.markdown("# Chat with multiple PDFs π")
|
74 |
|
75 |
st.write(css, unsafe_allow_html=True)
|
76 |
|
@@ -90,7 +90,7 @@ def main():
|
|
90 |
|
91 |
with st.sidebar:
|
92 |
st.subheader("Your documents")
|
93 |
-
st.
|
94 |
pdf_docs = st.file_uploader(
|
95 |
"Upload your PDFs here and click on 'Process'", accept_multiple_files=True
|
96 |
)
|
|
|
3 |
import streamlit as st
|
4 |
from PyPDF2 import PdfReader
|
5 |
from langchain.text_splitter import CharacterTextSplitter
|
6 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
7 |
from langchain.vectorstores import FAISS
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from langchain.chains import ConversationalRetrievalChain
|
|
|
29 |
|
30 |
|
31 |
def get_vectorstore(text_chunks):
|
32 |
+
model = "sentence-transformers/all-MiniLM-L6-v2"
|
33 |
encode_kwargs = {
|
34 |
"normalize_embeddings": True
|
35 |
}
|
36 |
+
embeddings = HuggingFaceEmbeddings(
|
37 |
model_name=model, encode_kwargs=encode_kwargs, model_kwargs={"device": "cpu"}
|
38 |
)
|
39 |
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
|
|
70 |
page_icon="π",
|
71 |
)
|
72 |
|
73 |
+
st.markdown("# Chatπ¬ with multiple PDFs π")
|
74 |
|
75 |
st.write(css, unsafe_allow_html=True)
|
76 |
|
|
|
90 |
|
91 |
with st.sidebar:
|
92 |
st.subheader("Your documents")
|
93 |
+
st.text("You can upload multiple files at once")
|
94 |
pdf_docs = st.file_uploader(
|
95 |
"Upload your PDFs here and click on 'Process'", accept_multiple_files=True
|
96 |
)
|