Download app.py from Dhruv0730/PDFREADER: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/spaces/Dhruv0730/PDFREADER/resolve/main/app.py
- Command line
-
hf download hf://spaces/Dhruv0730/PDFREADER/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Dhruv0730/PDFREADER/resolve/main/app.py
861 Bytes
| # -*- coding: utf-8 -*- | |
| """app.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1ELiw5PgFIpVzc3HtrCiyILA9HbrL-WXg | |
| """ | |
| import streamlit as st | |
| from backend import extract_text_from_pdf, generate_answer | |
| st.set_page_config(page_title="PDF Assistant Chatbot π€", page_icon="π") | |
| st.title("π PDF Assistant Chatbot π€") | |
| uploaded_pdf = st.file_uploader("Upload your PDF", type=["pdf"]) | |
| if uploaded_pdf: | |
| pdf_text = extract_text_from_pdf(uploaded_pdf) | |
| st.success("PDF uploaded and text extracted!") | |
| user_question = st.text_input("Ask a question about the PDF:") | |
| if st.button("Get Answer"): | |
| if user_question: | |
| with st.spinner("Finding the best answer..."): | |
| answer = generate_answer(user_question, pdf_text) | |
| st.success(answer) |