red1xe commited on
Commit
8e16848
1 Parent(s): 24b5efd
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -21,18 +21,13 @@ st.header("File Upload")
21
  files = st.file_uploader("Upload your files", accept_multiple_files=True, type="pdf")
22
 
23
  if files:
24
- st.header("Start Conversion")
25
- if st.button("Ready!"):
26
- with st.spinner("Creating chain..."):
27
  full_text = get_pdf_text(files)
28
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
29
  chunks = text_splitter.split_text(full_text)
30
  embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
31
  db = FAISS.from_texts(chunks, embeddings)
32
- memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True,)
33
- st.header("Chatbot")
34
- st.subheader("Ask a question")
35
- question = st.text_input("Question")
36
- if question:
37
- similar_response = db.similarity_search(query=question, k=3)
38
- st.write(similar_response)
 
21
  files = st.file_uploader("Upload your files", accept_multiple_files=True, type="pdf")
22
 
23
  if files:
24
+ question = st.text_input("Ask a question")
25
+ if st.button("Search"):
26
+ with st.spinner("Fetching 3 most similar matches..."):
27
  full_text = get_pdf_text(files)
28
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
29
  chunks = text_splitter.split_text(full_text)
30
  embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
31
  db = FAISS.from_texts(chunks, embeddings)
32
+ similar_response = db.similarity_search_with_relevance_scores(query=question, k=3)
33
+ st.write(similar_response)