drakkenheim-rag/app.py

61 lines
1.8 KiB
Python

"""
Drakkenheim RAG Application - Main Entry Point
A Streamlit-based RAG (Retrieval-Augmented Generation) application that allows users to
upload documents and ask questions about their content using OpenAI's GPT models.
This is the main application file that orchestrates all the modules.
"""
import os
import warnings
import streamlit as st
# Import our custom modules
from src.drakkenheim import check_authentication, login_form, load_processed_files, render_sidebar, render_chat_interface
# Set environment variables to suppress warnings
os.environ["TOKENIZERS_PARALLELISM"] = "false"
os.environ["CHROMA_TELEMETRY"] = "false"
os.environ["TOKENIZERS_VERBOSITY"] = "error"
# Suppress specific warnings
warnings.filterwarnings("ignore", category=UserWarning, module="sentence_transformers")
warnings.filterwarnings("ignore", category=UserWarning, module="transformers")
warnings.filterwarnings("ignore", category=FutureWarning)
def main():
"""Main application function."""
# Set page configuration
st.set_page_config(
page_title="RAG Chat Assistant",
page_icon="🤖",
layout="wide"
)
# Check authentication first
if not check_authentication():
login_form()
return
# Initialize session state
if "messages" not in st.session_state:
st.session_state.messages = []
if "documents_loaded" not in st.session_state:
st.session_state.documents_loaded = False
if "processed_files" not in st.session_state:
st.session_state.processed_files = []
if "files_loaded" not in st.session_state:
st.session_state.files_loaded = False
load_processed_files()
# Render the application
render_sidebar()
render_chat_interface()
if __name__ == "__main__":
main()