Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import os | |
| from src.langgraphagenticai.ui.uiconfigfile import Config | |
| class LoadStreamlitUI: | |
| def __init__(self): | |
| self.config = Config() | |
| self.user_controls = {} | |
| def _inject_custom_css(self): | |
| """Inject custom CSS with elegant dark and light purple two-tone design""" | |
| st.markdown(""" | |
| <style> | |
| /* Main container styling - dark with subtle purple undertones */ | |
| .main { | |
| background: linear-gradient(135deg, #1a1625 0%, #2d2438 100%); | |
| background-attachment: fixed; | |
| } | |
| /* Header styling - elegant dark purple with light purple accents */ | |
| .custom-header { | |
| background: linear-gradient(135deg, #2d2438 0%, #3d3250 100%); | |
| padding: 2.5rem 3rem; | |
| border-radius: 16px; | |
| box-shadow: 0 10px 40px rgba(139, 92, 246, 0.15); | |
| margin-bottom: 2.5rem; | |
| text-align: center; | |
| border: 1px solid rgba(167, 139, 250, 0.15); | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .custom-header::before { | |
| content: ''; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| height: 2px; | |
| background: linear-gradient(90deg, transparent, #a78bfa, #c4b5fd, transparent); | |
| opacity: 0.7; | |
| } | |
| .custom-header h1 { | |
| color: #f3f4f6; | |
| font-size: 2.4rem; | |
| font-weight: 600; | |
| margin: 0; | |
| letter-spacing: 0.3px; | |
| text-shadow: 0 2px 15px rgba(167, 139, 250, 0.3); | |
| } | |
| /* Sidebar styling - deep dark with purple hints */ | |
| [data-testid="stSidebar"] { | |
| background: linear-gradient(180deg, #1a1625 0%, #0f0d15 100%); | |
| border-right: 1px solid rgba(167, 139, 250, 0.1); | |
| } | |
| [data-testid="stSidebar"] .css-1d391kg { | |
| padding: 2rem 1rem; | |
| } | |
| /* Selectbox styling with light purple accents */ | |
| .stSelectbox label { | |
| color: #e9d5ff !important; | |
| font-weight: 500; | |
| font-size: 0.95rem; | |
| margin-bottom: 0.5rem; | |
| } | |
| .stSelectbox > div > div { | |
| background-color: #2d2438; | |
| border: 1px solid #4c3d5f; | |
| border-radius: 8px; | |
| color: #f3e8ff; | |
| transition: all 0.3s ease; | |
| } | |
| .stSelectbox > div > div:hover { | |
| border-color: #7c3aed; | |
| background-color: #3d3250; | |
| box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.3); | |
| } | |
| /* Text input styling with purple glow */ | |
| .stTextInput label { | |
| color: #e9d5ff !important; | |
| font-weight: 500; | |
| font-size: 0.95rem; | |
| } | |
| .stTextInput > div > div > input { | |
| background-color: #2d2438; | |
| border: 1px solid #4c3d5f; | |
| border-radius: 8px; | |
| color: #f3e8ff; | |
| padding: 0.65rem; | |
| transition: all 0.3s ease; | |
| } | |
| .stTextInput > div > div > input:focus { | |
| border-color: #7c3aed; | |
| background-color: #3d3250; | |
| box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.25); | |
| outline: none; | |
| } | |
| .stTextInput > div > div > input::placeholder { | |
| color: #a78bfa; | |
| opacity: 0.6; | |
| } | |
| /* Warning box styling - elegant purple gradient */ | |
| .stAlert { | |
| background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%); | |
| border-radius: 8px; | |
| border: 1px solid #8b5cf6; | |
| padding: 1rem; | |
| color: #f3e8ff; | |
| font-weight: 400; | |
| box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2); | |
| } | |
| /* Link styling with light purple */ | |
| a { | |
| color: #c4b5fd !important; | |
| text-decoration: none; | |
| font-weight: 500; | |
| transition: color 0.2s ease; | |
| } | |
| a:hover { | |
| color: #ddd6fe !important; | |
| text-decoration: underline; | |
| } | |
| /* Clean section dividers with purple tint */ | |
| .section-divider { | |
| height: 1px; | |
| background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.3), transparent); | |
| margin: 2rem 0; | |
| } | |
| /* Robot emoji subtle animation */ | |
| @keyframes float { | |
| 0%, 100% { transform: translateY(0px); } | |
| 50% { transform: translateY(-8px); } | |
| } | |
| .robot-icon { | |
| display: inline-block; | |
| animation: float 4s ease-in-out infinite; | |
| } | |
| /* Section headers - light purple accents */ | |
| .section-header { | |
| color: #e9d5ff; | |
| font-size: 0.85rem; | |
| font-weight: 600; | |
| margin-bottom: 1rem; | |
| margin-top: 1.5rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| text-transform: uppercase; | |
| letter-spacing: 1px; | |
| } | |
| /* Remove extra spacing */ | |
| .stSelectbox, .stTextInput { | |
| margin-bottom: 1.5rem; | |
| } | |
| /* Toggle/Checkbox styling */ | |
| .stCheckbox label { | |
| color: #e9d5ff !important; | |
| } | |
| /* Overall text color adjustment with purple tint */ | |
| p, span, div { | |
| color: #e9d5ff; | |
| } | |
| /* Button styling (if you add buttons later) */ | |
| .stButton > button { | |
| background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%); | |
| color: #f3e8ff; | |
| border: 1px solid #a78bfa; | |
| border-radius: 8px; | |
| padding: 0.5rem 1.5rem; | |
| font-weight: 500; | |
| transition: all 0.3s ease; | |
| } | |
| .stButton > button:hover { | |
| background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%); | |
| box-shadow: 0 0 20px rgba(167, 139, 250, 0.4); | |
| border-color: #c4b5fd; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| def load_streamlit_ui(self): | |
| # Page config | |
| st.set_page_config( | |
| page_title="🤖 " + self.config.get_page_title(), | |
| layout="wide", | |
| initial_sidebar_state="expanded" | |
| ) | |
| # Inject custom CSS | |
| self._inject_custom_css() | |
| # Custom header with HTML - elegant and refined | |
| st.markdown(f""" | |
| <div class="custom-header"> | |
| <h1><span class="robot-icon">🤖</span> {self.config.get_page_title()}</h1> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| with st.sidebar: | |
| # Get options from config | |
| llm_options = self.config.get_llm_options() | |
| usecase_options = self.config.get_usecase_options() | |
| # AI Configuration section header | |
| st.markdown("<div class='section-header'>🧠 AI Configuration</div>", unsafe_allow_html=True) | |
| # LLM selection | |
| self.user_controls["selected_llm"] = st.selectbox( | |
| "Select LLM", | |
| llm_options, | |
| help="Choose your preferred Language Model" | |
| ) | |
| if self.user_controls["selected_llm"] == 'Groq': | |
| # Model selection | |
| model_options = self.config.get_groq_model_options() | |
| self.user_controls["selected_groq_model"] = st.selectbox( | |
| "Select Model", | |
| model_options, | |
| help="Choose a Groq model variant" | |
| ) | |
| self.user_controls["GROQ_API_KEY"] = st.session_state["GROQ_API_KEY"] = st.text_input( | |
| "API Key", | |
| type="password", | |
| placeholder="Enter your Groq API key" | |
| ) | |
| # Validate API key | |
| if not self.user_controls["GROQ_API_KEY"]: | |
| st.warning("⚠️ Please enter your GROQ API key to proceed. Don't have one? Get it here: [Groq Console](https://console.groq.com/keys)") | |
| # Divider | |
| st.markdown("<div class='section-divider'></div>", unsafe_allow_html=True) | |
| # Use Case section header | |
| st.markdown("<div class='section-header'>🎯 Use Case</div>", unsafe_allow_html=True) | |
| # Usecase selection | |
| self.user_controls["selected_usecase"] = st.selectbox( | |
| "Select Usecases", | |
| usecase_options, | |
| help="Choose your application use case" | |
| ) | |
| return self.user_controls | |