Spaces:
Runtime error
Runtime error
File size: 3,154 Bytes
816825a |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import streamlit as st
def setup_page_config():
st.set_page_config(
page_title="RAG Document System",
page_icon="π",
layout="centered"
)
def load_custom_css():
st.markdown("""
<style>
.info-box {
background-color: #f0f2f6;
color: #000;
padding: 0.5rem;
margin: 0.5rem;
border-radius: 0.5rem;
border-left: 4px solid #1f77b4;
}
</style>
""", unsafe_allow_html=True)
def render_header():
st.markdown('<h1 class="main-header">π RAG Document System</h1>', unsafe_allow_html=True)
st.markdown('<h2 class="sub-header">Upload and interact with your documents</h2>', unsafe_allow_html=True)
def render_getting_started():
st.markdown("""
<div class="info-box">
<h4>Getting Started</h4>
<p>1. Upload a text document (.txt) using the file uploader above</p>
<p>2. Wait for the document to be processed</p>
<p>3. Start asking questions about your document!</p>
</div>
""", unsafe_allow_html=True)
def render_system_info(system_info: dict):
"""Render system information"""
with st.expander("π§ System Information"):
if not system_info:
st.info("System information not available")
return
# Basic configuration
st.markdown("**Configuration:**")
col1, col2 = st.columns(2)
with col1:
st.write(f"β’ Chunk Size: {system_info.get('chunk_size', 'N/A')}")
st.write(f"β’ Chunk Overlap: {system_info.get('chunk_overlap', 'N/A')}")
st.write(f"β’ Temperature: {system_info.get('temperature', 'N/A')}")
with col2:
st.write(f"β’ Embedding Model: {system_info.get('embedding_model', 'N/A')}")
st.write(f"β’ Persist Directory: {system_info.get('persist_directory', 'N/A')}")
# Component status
st.markdown("**Component Status:**")
components = system_info.get('components_initialized', {})
for component, status in components.items():
status_icon = "β
" if status else "β"
st.write(f"{status_icon} {component.replace('_', ' ').title()}")
# Embedding info
if 'embedding_info' in system_info:
st.markdown("**Embedding Model Info:**")
embedding_info = system_info['embedding_info']
st.write(f"β’ Model: {embedding_info.get('model_name', 'N/A')}")
st.write(f"β’ Device: {embedding_info.get('device', 'N/A')}")
st.write(f"β’ Dimensions: {embedding_info.get('dimension', 'N/A')}")
# Vector store stats
if 'vector_store_stats' in system_info:
st.markdown("**Vector Store Stats:**")
vector_stats = system_info['vector_store_stats']
st.write(f"β’ Total Documents: {vector_stats.get('total_documents', 0)}")
st.write(f"β’ Collection: {vector_stats.get('collection_name', 'N/A')}")
def render_processing_spinner(message: str = "Processing..."):
return st.spinner(message)
|