Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
test fix for chromadb persistence bug
Browse files- app_gradio.py +6 -1
app_gradio.py
CHANGED
|
@@ -314,9 +314,14 @@ def run_rag_qa(query, papers_df, question_type):
|
|
| 314 |
documents.append(doc)
|
| 315 |
|
| 316 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=150, chunk_overlap=50, add_start_index=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
splits = text_splitter.split_documents(documents)
|
| 318 |
vectorstore = Chroma.from_documents(documents=splits, embedding=embeddings, collection_name='retdoc4')
|
| 319 |
-
retriever = vectorstore.as_retriever(search_type="similarity", search_kwargs={"k":
|
| 320 |
|
| 321 |
if question_type == 'Bibliometric':
|
| 322 |
template = bibliometric_prompt
|
|
|
|
| 314 |
documents.append(doc)
|
| 315 |
|
| 316 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=150, chunk_overlap=50, add_start_index=True)
|
| 317 |
+
|
| 318 |
+
try:
|
| 319 |
+
del vectorstore, splits
|
| 320 |
+
except:
|
| 321 |
+
print('no vectorstore found, initializing')
|
| 322 |
splits = text_splitter.split_documents(documents)
|
| 323 |
vectorstore = Chroma.from_documents(documents=splits, embedding=embeddings, collection_name='retdoc4')
|
| 324 |
+
retriever = vectorstore.as_retriever(search_type="similarity", search_kwargs={"k": len(documents)})
|
| 325 |
|
| 326 |
if question_type == 'Bibliometric':
|
| 327 |
template = bibliometric_prompt
|