Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,56 @@
|
|
1 |
import os
|
2 |
-
|
|
|
|
|
3 |
from rag_utility import process_document_to_chromadb, answer_question
|
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 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
from rag_utility import process_document_to_chromadb, answer_question
|
6 |
|
7 |
+
|
8 |
+
# Set working directory (optional, ensures saving in project dir)
|
9 |
+
working_dir = os.getcwd()
|
10 |
+
|
11 |
+
st.title("π DeepSeek-R1 vs π¦ Llama-3")
|
12 |
+
|
13 |
+
# File uploader
|
14 |
+
uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])
|
15 |
+
|
16 |
+
if uploaded_file is not None:
|
17 |
+
# Define save path
|
18 |
+
save_path = os.path.join(working_dir, uploaded_file.name)
|
19 |
+
# Save file
|
20 |
+
with open(save_path, "wb") as f:
|
21 |
+
f.write(uploaded_file.getbuffer())
|
22 |
+
|
23 |
+
process_documents = process_document_to_chromadb(uploaded_file.name)
|
24 |
+
st.info("Document Processed Successfully")
|
25 |
+
|
26 |
+
|
27 |
+
user_question = st.text_area("Ask your question from the document")
|
28 |
+
|
29 |
+
if st.button("Answer"):
|
30 |
+
answer = answer_question(user_question)
|
31 |
+
answer_deepseek = answer["answer_deepseek"]
|
32 |
+
answer_llama3 = answer["answer_llama3"]
|
33 |
+
|
34 |
+
col1, col2 = st.columns(2)
|
35 |
+
|
36 |
+
with col1:
|
37 |
+
st.markdown("### DeepSeek-r1 Response")
|
38 |
+
st.markdown(
|
39 |
+
f"""
|
40 |
+
<div style="border: 1px solid #ccc; padding: 10px; border-radius: 5px; background-color: #f9f9f9;">
|
41 |
+
{answer_deepseek}
|
42 |
+
</div>
|
43 |
+
""",
|
44 |
+
unsafe_allow_html=True
|
45 |
+
)
|
46 |
+
|
47 |
+
with col2:
|
48 |
+
st.markdown("### Llama-3 Response")
|
49 |
+
st.markdown(
|
50 |
+
f"""
|
51 |
+
<div style="border: 1px solid #ccc; padding: 10px; border-radius: 5px; background-color: #f9f9f9;">
|
52 |
+
{answer_llama3}
|
53 |
+
</div>
|
54 |
+
""",
|
55 |
+
unsafe_allow_html=True
|
56 |
+
)
|