Update app.py
Browse files
app.py
CHANGED
@@ -76,7 +76,7 @@ def save_as_txt(conversation):
|
|
76 |
st.markdown(f"Download [TXT](./{txt_filename})")
|
77 |
|
78 |
def main():
|
79 |
-
st.markdown('<h1>Ask anything from
|
80 |
st.markdown("<h2>Upload documents</h2>", unsafe_allow_html=True)
|
81 |
uploaded_files = st.file_uploader("Upload one or more documents", type=['pdf', 'docx'], accept_multiple_files=True)
|
82 |
question = st.text_input("Ask a question based on the documents", key="question_input")
|
@@ -91,7 +91,7 @@ def main():
|
|
91 |
for uploaded_file in uploaded_files:
|
92 |
paragraphs = search.read_pdf_pdfminer(uploaded_file) if uploaded_file.type == "application/pdf" else search.read_docx(uploaded_file)
|
93 |
temp_df = pd.DataFrame(
|
94 |
-
[(p.page_num, p.paragraph_num, p.content, search.count_tokens(p.content
|
95 |
for p in paragraphs],
|
96 |
columns=["page_num", "paragraph_num", "content", "tokens"]
|
97 |
)
|
@@ -103,7 +103,7 @@ def main():
|
|
103 |
answer = ""
|
104 |
if question != st.session_state.get("last_question", ""):
|
105 |
st.text("Searching...")
|
106 |
-
answer = search.answer_query_with_context(question, df
|
107 |
st.session_state["interactions"].append((question, answer))
|
108 |
st.write(answer)
|
109 |
|
|
|
76 |
st.markdown(f"Download [TXT](./{txt_filename})")
|
77 |
|
78 |
def main():
|
79 |
+
st.markdown('<h1>Ask anything from Legal Texts</h1><p style="font-size: 12; color: gray;"></p>', unsafe_allow_html=True)
|
80 |
st.markdown("<h2>Upload documents</h2>", unsafe_allow_html=True)
|
81 |
uploaded_files = st.file_uploader("Upload one or more documents", type=['pdf', 'docx'], accept_multiple_files=True)
|
82 |
question = st.text_input("Ask a question based on the documents", key="question_input")
|
|
|
91 |
for uploaded_file in uploaded_files:
|
92 |
paragraphs = search.read_pdf_pdfminer(uploaded_file) if uploaded_file.type == "application/pdf" else search.read_docx(uploaded_file)
|
93 |
temp_df = pd.DataFrame(
|
94 |
+
[(p.page_num, p.paragraph_num, p.content, search.count_tokens(p.content))
|
95 |
for p in paragraphs],
|
96 |
columns=["page_num", "paragraph_num", "content", "tokens"]
|
97 |
)
|
|
|
103 |
answer = ""
|
104 |
if question != st.session_state.get("last_question", ""):
|
105 |
st.text("Searching...")
|
106 |
+
answer = search.answer_query_with_context(question, df)
|
107 |
st.session_state["interactions"].append((question, answer))
|
108 |
st.write(answer)
|
109 |
|