Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,8 +67,8 @@ def generate_response(query, context):
|
|
67 |
return tokenizer.batch_decode(output, skip_special_tokens=True)[0]
|
68 |
|
69 |
# Streamlit UI
|
70 |
-
st.set_page_config(page_title="π
|
71 |
-
st.title("π
|
72 |
st.subheader("Upload documents and ask questions!")
|
73 |
|
74 |
uploaded_files = st.file_uploader("Upload PDFs or TXT files", accept_multiple_files=True)
|
@@ -78,10 +78,13 @@ if uploaded_files:
|
|
78 |
process_documents(uploaded_files)
|
79 |
st.success("Documents uploaded and indexed!")
|
80 |
|
81 |
-
query
|
82 |
-
if
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
67 |
return tokenizer.batch_decode(output, skip_special_tokens=True)[0]
|
68 |
|
69 |
# Streamlit UI
|
70 |
+
st.set_page_config(page_title="π Smart Study", page_icon="π€")
|
71 |
+
st.title("π Q&A using IBM Granite")
|
72 |
st.subheader("Upload documents and ask questions!")
|
73 |
|
74 |
uploaded_files = st.file_uploader("Upload PDFs or TXT files", accept_multiple_files=True)
|
|
|
78 |
process_documents(uploaded_files)
|
79 |
st.success("Documents uploaded and indexed!")
|
80 |
|
81 |
+
if query:
|
82 |
+
if index.ntotal == 0: # Ensure documents are indexed before querying
|
83 |
+
st.warning("Please upload and process documents first!")
|
84 |
+
else:
|
85 |
+
with st.spinner("Retrieving and generating response..."):
|
86 |
+
context = retrieve_context(query)
|
87 |
+
response = generate_response(query, context)
|
88 |
+
st.markdown("### π€ Answer:")
|
89 |
+
st.write(response)
|
90 |
+
|