File size: 861 Bytes
b0d197f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# -*- 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) |