deneme
Browse files
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.
|
| 25 |
-
if st.button("
|
| 26 |
-
with st.spinner("
|
| 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 |
-
|
| 33 |
-
st.
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|