import streamlit as st
import os
import base64
from PIL import Image
import io
DEFAULT_SESSION_STATE = {
# PDF Upload
'uploaded_files_name': [],
'collections_files_name': [],
'uploaded_files_raw': [],
}
def configure_page() -> None:
"""
Configures the Streamlit page.
"""
st.set_page_config(page_title="myRAG",
layout="wide",
page_icon=":rocket:")
def apply_style():
st.markdown("""
""", unsafe_allow_html=True)
def breaks(n=1):
"""
Creates a line break.
"""
if n == 1:
st.markdown("
",unsafe_allow_html=True)
elif n == 2:
st.markdown("
",unsafe_allow_html=True)
elif n == 3:
st.markdown("
",unsafe_allow_html=True)
else:
st.markdown("
",unsafe_allow_html=True)
def load_background_image():
"""
Loads and displays a background image with an overlaid title.
Uses PIL for safer image processing that passes HF security scans.
"""
possible_paths = [
"../images/image6.jpg", # Local development (from src/ folder)
"images/image6.jpg", # Docker container (from /app)
"./images/image6.jpg", # Current directory
]
image_path = None
for path in possible_paths:
if os.path.exists(path):
image_path = path
break
if not image_path:
st.error("Could not find image6.jpg in any expected location")
return
try:
# Use PIL for safe image processing (avoids HF pickle scanner issues)
img = Image.open(image_path)
# Convert to PNG format in memory for consistency
img_buffer = io.BytesIO()
img.save(img_buffer, format='PNG')
img_bytes = img_buffer.getvalue()
# Encode to base64
base64_image = base64.b64encode(img_bytes).decode()
# Inject CSS for the background and title overlay
st.markdown(
f"""
""",
unsafe_allow_html=True
)
# Create the background container with an overlaid title
st.markdown(
"""