Spaces:
Sleeping
Sleeping
Download app.py from PavanKumarD/FinBot: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/PavanKumarD/FinBot/resolve/495c58616f14c5975e4e06d77e142991c55676cd/app.py
- Command line
-
hf download hf://spaces/PavanKumarD/FinBot@495c58616f14c5975e4e06d77e142991c55676cd/app.py
-
curl -L -o app.py https://huggingface.co/spaces/PavanKumarD/FinBot/resolve/495c58616f14c5975e4e06d77e142991c55676cd/app.py
1.06 kB
| import streamlit as st | |
| from backend import extract_text_from_pdf, split_into_chunks, build_faiss_index, generate_answer, set_user_data | |
| st.set_page_config(page_title="FinBot RAG", layout="centered") | |
| st.title("π€ FinBot β RAG-based Banking Assistant") | |
| # Upload Banking Knowledge Base PDF | |
| banking_pdf = st.file_uploader("π Upload Banking Knowledge PDF", type=["pdf"]) | |
| # Upload optional user-specific data | |
| user_pdf = st.file_uploader("π€ Upload Your Personal Banking Data (optional)", type=["pdf"]) | |
| if banking_pdf: | |
| with st.spinner("Indexing banking document..."): | |
| text = extract_text_from_pdf(banking_pdf) | |
| chunks = split_into_chunks(text) | |
| build_faiss_index(chunks) | |
| st.success("Banking document indexed successfully!") | |
| if user_pdf: | |
| set_user_data(user_pdf) | |
| st.success("User-specific data loaded!") | |
| # Chat interface | |
| query = st.text_input("π¬ Ask a financial question:") | |
| if query: | |
| with st.spinner("Generating response..."): | |
| answer = generate_answer(query) | |
| st.markdown(f"**Answer:** {answer}") | |