Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,12 +73,24 @@ if uploaded_file:
|
|
| 73 |
user_question = st.text_input("π¬ Type your question here")
|
| 74 |
|
| 75 |
if user_question:
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
user_question = st.text_input("π¬ Type your question here")
|
| 74 |
|
| 75 |
if user_question:
|
| 76 |
+
with st.spinner("π§ Thinking..."):
|
| 77 |
+
try:
|
| 78 |
+
# Optional: show what documents are retrieved before sending to LLM
|
| 79 |
+
retrieved_docs = vector_store.similarity_search(user_question, k=4)
|
| 80 |
+
if not retrieved_docs:
|
| 81 |
+
st.warning("β οΈ No relevant text chunks found for this question. Try a different question.")
|
| 82 |
+
else:
|
| 83 |
+
st.markdown("### π Top Relevant Chunks (raw):")
|
| 84 |
+
for i, doc in enumerate(retrieved_docs, 1):
|
| 85 |
+
st.code(doc.page_content[:300], language="markdown")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
answer = astra_vector_index.query(user_question, llm=llm)
|
| 89 |
+
if answer.strip():
|
| 90 |
+
st.markdown("### π§ Answer:")
|
| 91 |
+
st.write(answer.strip())
|
| 92 |
+
else:
|
| 93 |
+
st.warning("β οΈ The model returned an empty response. Try rephrasing the question or check your model/API key.")
|
| 94 |
+
except Exception as e:
|
| 95 |
+
st.error(f"π¨ Error while generating response:\n\n{str(e)}")
|
| 96 |
+
|