Spaces:
Sleeping
Sleeping
File size: 1,260 Bytes
fbfbbd7 |
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 33 34 35 36 37 38 39 40 41 42 43 44 |
import streamlit as st
import os
from dotenv import load_dotenv
from pdf_processor import PDFProcessor
from rag_engine import RAGEngine
from app.config import AZURE_OPENAI_DEPLOYMENT_NAME
# Load environment variables
load_dotenv()
# Initialize components
pdf_processor = PDFProcessor()
rag_engine = RAGEngine(deployment_name=AZURE_OPENAI_DEPLOYMENT_NAME)
def main():
st.set_page_config(
page_title="CRE Knowledge Assistant",
page_icon="🤖",
layout="wide"
)
st.title("CRE Knowledge Assistant 🏢")
# File uploader
uploaded_file = st.file_uploader("Upload a PDF document", type="pdf")
if uploaded_file:
try:
# Process the PDF
pdf_processor.process(uploaded_file)
st.success("PDF processed successfully! You can now ask questions about it.")
# Show chat interface
user_question = st.text_input("Ask a question about the document:")
if user_question:
response = rag_engine.get_response(user_question)
st.write("Answer:", response)
except Exception as e:
st.error(f"Error processing PDF: {str(e)}")
if __name__ == "__main__":
main()
|