forked from mmz-001/doc-qa-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
22 lines (18 loc) · 820 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import streamlit as st
from utils import parse_pdf, embed_text, get_answer
st.set_page_config(page_title="ChatDoc", page_icon=":book:", layout="wide")
hide_default_format = """
<style>
#MainMenu {visibility: hidden; }
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_default_format, unsafe_allow_html=True)
st.header("ChatDoc - The AI Bot Answering Your Questions based on a Document")
uploaded_file = st.file_uploader("Upload a PDF file, then you can ask questions, our ChatGPT will answer questions based on the document", type=["pdf"])
if uploaded_file is not None:
index = embed_text(parse_pdf(uploaded_file))
query = st.text_area("Ask a question about the document")
button = st.button("Submit")
if button:
st.write(get_answer(index, query))