scholarly360 commited on
Commit
d9ae846
·
1 Parent(s): b3db418

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -267,29 +267,19 @@ with st.form("my_form"):
267
  list_save_path.append(save_path)
268
 
269
  print('uploaded_files ', uploaded_files)
270
- if uploaded_files is not None:
 
 
271
  #list_docs, list_save_path = util_upload_file_and_return_list_docs(uploaded_files)
272
  print('list_docs ' ,list_docs)
273
  print('list_save_path ' , list_save_path)
274
-
275
- #page_documents , passage_documents = util_get_list_page_and_passage(docs)
276
- #print('len(page_documents) len(passage_documents ', len(page_documents), len(passage_documents))
277
- single_example_passage = st.text_area('Enter Query Here',"What is Governing Law ")
278
- #hyde_passage = util_openai_hyde(single_example_passage)
279
- #print("HYDE :: ", hyde_passage)
280
-
281
- submitted = st.form_submit_button("Index and Calculate")
282
- if submitted and (uploaded_file is not None):
283
  bm25_retriever = BM25Retriever.from_documents(passage_documents)
284
  bm25_retriever.k = 2
285
  chroma_vectorstore = Chroma.from_documents(passage_documents, embedding)
286
  chroma_retriever = chroma_vectorstore.as_retriever(search_kwargs={"k": 2})
287
- #initialize the ensemble retriever
288
  ensemble_retriever = EnsembleRetriever(retrievers=[bm25_retriever, chroma_retriever],weights=[0.25, 0.75])
289
  passage_nodes = ensemble_retriever.get_relevant_documents(single_example_passage)
290
  print('len(passage_nodes):', len(passage_nodes))
291
- ### From Passage to PAGE
292
-
293
  found_passage, page_list_retrieve = util_get_list_pageno_and_contents(single_example_passage, page_documents,passage_documents,passage_nodes)
294
  print('len(page_list_retrieve):', len(page_list_retrieve))
295
  if(len(page_list_retrieve)>0):
@@ -299,11 +289,8 @@ with st.form("my_form"):
299
  page_content = iindex[1]
300
  annotated_text(" ",annotation("RELEVANT PAGENO : ", str(page_no), font_family="Comic Sans MS", border="2px dashed red"),)
301
  util_openai_format(single_example_passage, page_content)
302
- #st.write('Modified Prompt :: ')
303
  annotated_text(" ",annotation("RELEVANT PASSAGE : ", "", font_family="Comic Sans MS", border="2px dashed red"),)
304
  st.write(found_passage)
305
- # util_del_file(save_path)
306
- # chroma_client.delete_collection(name=collection_name)
307
  pchroma_client = chromadb.Client()
308
  for citem in pchroma_client.list_collections():
309
  print(citem.name)
 
267
  list_save_path.append(save_path)
268
 
269
  print('uploaded_files ', uploaded_files)
270
+ single_example_passage = st.text_area('Enter Query Here',"What is Governing Law ")
271
+ submitted = st.form_submit_button("Index and Calculate")
272
+ if submitted and (uploaded_files is not None):
273
  #list_docs, list_save_path = util_upload_file_and_return_list_docs(uploaded_files)
274
  print('list_docs ' ,list_docs)
275
  print('list_save_path ' , list_save_path)
 
 
 
 
 
 
 
 
 
276
  bm25_retriever = BM25Retriever.from_documents(passage_documents)
277
  bm25_retriever.k = 2
278
  chroma_vectorstore = Chroma.from_documents(passage_documents, embedding)
279
  chroma_retriever = chroma_vectorstore.as_retriever(search_kwargs={"k": 2})
 
280
  ensemble_retriever = EnsembleRetriever(retrievers=[bm25_retriever, chroma_retriever],weights=[0.25, 0.75])
281
  passage_nodes = ensemble_retriever.get_relevant_documents(single_example_passage)
282
  print('len(passage_nodes):', len(passage_nodes))
 
 
283
  found_passage, page_list_retrieve = util_get_list_pageno_and_contents(single_example_passage, page_documents,passage_documents,passage_nodes)
284
  print('len(page_list_retrieve):', len(page_list_retrieve))
285
  if(len(page_list_retrieve)>0):
 
289
  page_content = iindex[1]
290
  annotated_text(" ",annotation("RELEVANT PAGENO : ", str(page_no), font_family="Comic Sans MS", border="2px dashed red"),)
291
  util_openai_format(single_example_passage, page_content)
 
292
  annotated_text(" ",annotation("RELEVANT PASSAGE : ", "", font_family="Comic Sans MS", border="2px dashed red"),)
293
  st.write(found_passage)
 
 
294
  pchroma_client = chromadb.Client()
295
  for citem in pchroma_client.list_collections():
296
  print(citem.name)