Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ from langchain_community.document_loaders import PDFPlumberLoader
|
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
from langchain_core.vectorstores import InMemoryVectorStore
|
| 7 |
from langchain_core.prompts import ChatPromptTemplate
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Set up Hugging Face model and token
|
| 10 |
model = "mistralai/Mixtral-8x7B-Instruct-v0.1" # You can change to a model of your choice from Hugging Face
|
|
@@ -23,8 +25,11 @@ Answer:
|
|
| 23 |
pdfs_directory = '../pdfs'
|
| 24 |
os.makedirs(pdfs_directory, exist_ok=True)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
# Initialize the vector store for document indexing
|
| 27 |
-
vector_store = InMemoryVectorStore()
|
| 28 |
|
| 29 |
# Function to upload PDF file
|
| 30 |
def upload_pdf(file):
|
|
|
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
from langchain_core.vectorstores import InMemoryVectorStore
|
| 7 |
from langchain_core.prompts import ChatPromptTemplate
|
| 8 |
+
from langchain.embeddings import OpenAIEmbeddings
|
| 9 |
+
|
| 10 |
|
| 11 |
# Set up Hugging Face model and token
|
| 12 |
model = "mistralai/Mixtral-8x7B-Instruct-v0.1" # You can change to a model of your choice from Hugging Face
|
|
|
|
| 25 |
pdfs_directory = '../pdfs'
|
| 26 |
os.makedirs(pdfs_directory, exist_ok=True)
|
| 27 |
|
| 28 |
+
# Initialize the embedding model
|
| 29 |
+
embedding = OpenAIEmbeddings()
|
| 30 |
+
|
| 31 |
# Initialize the vector store for document indexing
|
| 32 |
+
vector_store = InMemoryVectorStore(embedding=embedding)
|
| 33 |
|
| 34 |
# Function to upload PDF file
|
| 35 |
def upload_pdf(file):
|