Update app.py
Browse files
app.py
CHANGED
@@ -257,30 +257,32 @@ document_chain = create_stuff_documents_chain(llm, prompt)
|
|
257 |
retriever = st.session_state.vector.as_retriever()
|
258 |
retrieval_chain = create_retrieval_chain(retriever, document_chain)
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
#
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
#
|
276 |
-
|
277 |
-
#
|
278 |
-
|
279 |
-
|
280 |
-
|
|
|
|
|
281 |
|
282 |
|
283 |
-
|
284 |
-
|
285 |
|
286 |
-
st.write("---------------------------------")
|
|
|
257 |
retriever = st.session_state.vector.as_retriever()
|
258 |
retrieval_chain = create_retrieval_chain(retriever, document_chain)
|
259 |
|
260 |
+
while True:
|
261 |
+
|
262 |
+
prompt = st.text_input("Input your prompt here")
|
263 |
+
|
264 |
+
|
265 |
+
# If the user hits enter
|
266 |
+
if prompt:
|
267 |
+
# Then pass the prompt to the LLM
|
268 |
+
start = time.process_time()
|
269 |
+
response = retrieval_chain.invoke({"input": prompt})
|
270 |
+
# print(f"Response time: {time.process_time() - start}")
|
271 |
+
st.write(f"Response time: {time.process_time() - start} seconds")
|
272 |
+
|
273 |
+
st.write(response["answer"])
|
274 |
+
|
275 |
+
# With a streamlit expander
|
276 |
+
with st.expander("Document Similarity Search"):
|
277 |
+
# Find the relevant chunks
|
278 |
+
for i, doc in enumerate(response["context"]):
|
279 |
+
# print(doc)
|
280 |
+
# st.write(f"Source Document # {i+1} : {doc.metadata['source'].split('/')[-1]}")
|
281 |
+
st.write(doc)
|
282 |
+
st.write(f"Source Document # {i+1} : {doc.metadata['source'].split('/')[-1]}")
|
283 |
|
284 |
|
285 |
+
st.write(doc.page_content)
|
286 |
+
st.write("--------------------------------")
|
287 |
|
288 |
+
st.write("---------------------------------")
|