update retriever
Browse files
app.py
CHANGED
|
@@ -200,17 +200,26 @@ async def process_uploaded_files(files, model_name=PDF_MODEL_ID):
|
|
| 200 |
# Data processing and initialization
|
| 201 |
vectorstore = process_initial_embeddings()
|
| 202 |
|
| 203 |
-
|
| 204 |
-
# Create a retriever from the vector store
|
| 205 |
if vectorstore:
|
| 206 |
-
|
| 207 |
-
|
|
|
|
| 208 |
else:
|
| 209 |
-
print("Failed to create retriever: No vector store available.")
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
RAG_TEMPLATE = """\
|
| 215 |
You are a helpful and kind assistant. Use the context provided below to answer the question.
|
| 216 |
|
|
@@ -227,8 +236,9 @@ rag_prompt = ChatPromptTemplate.from_template(RAG_TEMPLATE)
|
|
| 227 |
|
| 228 |
chat_model = ChatOpenAI()
|
| 229 |
|
|
|
|
| 230 |
initialembeddings_retrieval_chain = (
|
| 231 |
-
{"context": itemgetter("question") |
|
| 232 |
"question": itemgetter("question")}
|
| 233 |
| rag_prompt
|
| 234 |
| chat_model
|
|
|
|
| 200 |
# Data processing and initialization
|
| 201 |
vectorstore = process_initial_embeddings()
|
| 202 |
|
| 203 |
+
# Create retrievers for each collection
|
|
|
|
| 204 |
if vectorstore:
|
| 205 |
+
# Retriever for initial Excel embeddings
|
| 206 |
+
excel_retriever = vectorstore.as_retriever(search_kwargs={"k": 10})
|
| 207 |
+
print("Excel retriever created successfully.")
|
| 208 |
else:
|
| 209 |
+
print("Failed to create Excel retriever: No vector store available.")
|
| 210 |
+
|
| 211 |
+
# The PDF retriever is created dynamically when files are uploaded
|
| 212 |
+
# in the embed_pdf_chunks_in_qdrant function:
|
| 213 |
+
#
|
| 214 |
+
# user_vectorstore = QdrantVectorStore(
|
| 215 |
+
# client=qdrant_client,
|
| 216 |
+
# collection_name=USER_EMBEDDINGS_NAME,
|
| 217 |
+
# embedding=pdf_model
|
| 218 |
+
# )
|
| 219 |
+
#
|
| 220 |
+
# user_retriever = user_vectorstore.as_retriever(search_kwargs={"k": top_k})
|
| 221 |
+
|
| 222 |
+
# RAG setup for Excel data
|
| 223 |
RAG_TEMPLATE = """\
|
| 224 |
You are a helpful and kind assistant. Use the context provided below to answer the question.
|
| 225 |
|
|
|
|
| 236 |
|
| 237 |
chat_model = ChatOpenAI()
|
| 238 |
|
| 239 |
+
# Chain for retrieving from Excel embeddings
|
| 240 |
initialembeddings_retrieval_chain = (
|
| 241 |
+
{"context": itemgetter("question") | excel_retriever | format_docs,
|
| 242 |
"question": itemgetter("question")}
|
| 243 |
| rag_prompt
|
| 244 |
| chat_model
|