-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (23 loc) · 953 Bytes
/
Copy pathapp.py
File metadata and controls
32 lines (23 loc) · 953 Bytes
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
29
30
31
32
import os
import streamlit as st
from rag_utils import process_document_to_chroma_db, answer_question
# Set the working directory
working_directory = os.path.dirname(os.path.abspath(__file__))
st.title("🦙 Llama-3.3-708 Document RAG")
# File uploader widget
uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])
if uploaded_file is not None:
# Define save path
save_path = os.path.join(working_directory, uploaded_file.name)
# Save the file
with open(save_path, "wb") as f:
f.write(uploaded_file.getbuffer())
# Process the document (pass full path if needed)
process_document_to_chroma_db(save_path)
st.info("✅ Document Processed Successfully!")
# Text input for user question
user_question = st.text_area("Ask your question about the document")
if st.button("Answer"):
answer = answer_question(user_question)
st.markdown("### 🤖 Llama-3.3-708 Response:")
st.markdown(answer)