Document Ready for Questions
You can now ask questions about the content of your document.
""", unsafe_allow_html=True)
# Chat interface
st.markdown("### Chat with your Document")
# Display conversation history with modern chat bubbles
for q, a in st.session_state.document_conversation:
with st.chat_message("user", avatar="đ¤"):
st.write(q)
with st.chat_message("assistant", avatar="đ¤"):
st.write(a)
# Question input with modern chat input
question = st.chat_input("Ask a question about your document...")
if question:
with st.chat_message("user", avatar="đ¤"):
st.write(question)
with st.chat_message("assistant", avatar="đ¤"):
with st.spinner("Analyzing document..."):
additional_context = "" # Can be modified to add external context if needed
result = chain.invoke({
"input": question,
"additional_context": additional_context
})
answer = result['answer']
st.write(answer)
# Store in conversation history
st.session_state.document_conversation.append((question, answer))
except Exception as e:
st.error(f"An error occurred: {str(e)}")
elif not (groq_key and gemini_key and pinecone_key):
# API key warning with modern alert
st.warning("â ī¸ Please make sure all API keys are properly configured in your environment variables.")
def display_web_search():
# Modern header with icon and description
st.markdown("""