-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (23 loc) · 867 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
from utils import PopulateDatabase, query_rag
# Set the title of the app
st.title("Local RAG - Chat with your PDF documents!")
# Create a button
load_button = st.button("Load Documents")
# Create another button to reset the database
reset_checkbox = st.checkbox("Reset Database")
if load_button:
db_populator = PopulateDatabase(reset=reset_checkbox)
if db_populator.reset:
st.write("Clearing and re-populating the database! Please wait...")
db_populator.execute()
st.write("Documents loaded successfully!")
st.divider()
query = st.text_input("Enter your question here : ")
query_button = st.button("Submit")
if query_button:
response, sources = query_rag(query)
st.write(f"{response}")
# Create an expander
with st.expander("Click to check sources"):
st.write(f"Sources: {sources}")