""" Utility functions for the AI Chatbot application. """ def format_chat_message(role: str, content: str) -> dict: """Format a chat message for the chatbot component.""" return {"role": role, "content": content} def validate_message(message: str) -> bool: """Validate that a message is safe and appropriate.""" # Simple validation - in production you'd want more robust checks forbidden_words = ["hate", "violence", "harm"] # Basic content filtering return not any(word in message.lower() for word in forbidden_words) def get_timestamp() -> str: """Get current timestamp for logging.""" from datetime import datetime return datetime.now().strftime("%Y-%m-%d %H:%M:%S") } This AI chatbot application features: ## 🎨 Modern Design - **Custom Soft theme** with indigo primary colors - **Google Inter font** for clean typography - **Responsive layout** that works on different screen sizes - **Professional UI** with proper spacing and sizing ## 🤖 Core Features - **Interactive chat interface** with message history - **Streaming responses** for natural conversation flow - **Message actions**: Like and Retry functionality - **Chat examples** for users to try - **Clear chat functionality** ## 🚀 Gradio 6 Best Practices - ✅ **Theme in demo.launch()** - Correct Gradio 6 syntax - ✅ **Proper event handling** with api_visibility parameter - ✅ **Responsive components** with appropriate sizing - ✅ **Error handling** and user feedback - ✅ **Clean code structure** with proper documentation ## 📱 User Experience - **Intuitive input** with placeholder text - **Visual feedback** through info/warning messages - **Copy and share** buttons for chat messages - **Accessibility** with proper labels and descriptions The chatbot uses simulated AI responses with pattern matching, but you can easily replace this with actual AI model integrations (OpenAI, Hugging Face, etc.).