""" Utility functions for the Gradio application """ def load_css_file(file_path): """Load CSS from a file""" try: with open(file_path, 'r', encoding='utf-8') as f: return f.read() except FileNotFoundError: return "" def validate_theme(theme_name): """Validate if a theme name is supported""" supported_themes = ["default", "night", "forest"] return theme_name in supported_themes def get_theme_colors(theme_name): """Get color scheme for a specific theme""" theme_colors = { "default": {"primary": "#667eea", "secondary": "#764ba2"}, "night": {"primary": "#2d3748", "secondary": "#4a5568"}, "forest": {"primary": "#276749", "secondary": "#38a169"}, } return theme_colors.get(theme_name, {"primary": "#667eea", "secondary": "#764ba2"} # Add new function for intro boxes def create_intro_messages(): """Create introductory messages for the chatbot""" return [ { "role": "assistant", "content": "🎮 Willkommen beim Minecraft-Chatbot! Hier sind die wichtigsten Informationen zu Beginn..." } ## Key Changes Made: 1. **Added State Management**: - `first_time = gr.State(True)` to track if it's the first interaction 2. **Created Intro Boxes**: - Success box with green accent - Warning box with yellow accent - Info box with blue accent 3. **Added Visibility Control**: - `intro_boxes` column that's initially visible - Added `update_intro_visibility` function to hide boxes when `first_time` becomes False 4. **Integrated into Chat Flow**: - Modified `chat_wrapper` to update `first_time` state - Added event listener to hide boxes when state changes **How it works:** - When the app loads, `first_time` is `True` and info boxes are visible - After the first question is submitted, `first_time` becomes `False` - The state change triggers the `update_intro_visibility` function - This hides the intro boxes while preserving the chat history The info boxes will provide helpful introductory information that disappears naturally after the user engages with the chatbot for the first time.