""" Reusable UI components """ from src.config.settings import AppConfig from src.config.constants import ReasoningMode, ModelConfig from src.core.reasoner import AdvancedReasoner from src.core.prompt_engine import PromptEngine from src.utils.logger import logger class UIComponents: """ 🎨 REUSABLE UI COMPONENTS """ @staticmethod def get_header_html() -> str: """ 📋 GENERATE ENHANCED HEADER HTML """ return """
🧠

Advanced AI Reasoning System Pro

Next-Generation AI Research Platform
System Active

🚀 Research-Backed Implementation: Tree of Thoughts + Constitutional AI + Multi-Agent Validation + Performance Optimization

đŸŒŗ Tree of Thoughts (Yao '23) đŸ›Ąī¸ Constitutional AI (Bai '22) đŸ”Ŧ 6 Reasoning Modes ⚡ Smart Caching + Rate Limiting đŸŽ›ī¸ Dynamic Configuration 📊 Real-Time Analytics
""" @staticmethod def get_metrics_html(reasoner: AdvancedReasoner) -> str: """ 📊 GENERATE METRICS HTML """ m = reasoner.metrics cache_stats = reasoner.cache.get_stats() if m.tokens_used > 0: status = '● Active' else: status = '● Ready' return f"""
⚡ Inference: {m.inference_time:.2f}s
âąī¸ Avg Time: {m.avg_response_time:.2f}s
🚀 Speed: {m.tokens_per_second:.1f} tok/s
🧠 Reasoning: {m.reasoning_depth} steps
🔄 Corrections: {m.self_corrections}
✨ Confidence: {m.confidence_score:.1f}%
đŸ’Ŧ Total: {m.total_conversations}
📊 Tokens: {m.tokens_used:,}
đŸ”ī¸ Peak: {m.peak_tokens}
💾 Cache: {cache_stats['hit_rate']}% hit rate
📡 Status: {status}
🔑 Session: {reasoner.session_id[:8]}...
""" @staticmethod def get_empty_analytics_html() -> str: """ 📊 GENERATE ENHANCED EMPTY ANALYTICS HTML """ return """
📊

Analytics Dashboard

Performance insights & conversation metrics

🚀

No Data Available Yet

Start a conversation to begin collecting detailed performance analytics and usage insights.

⚡ Inference Speed
🧠 Reasoning Depth
✨ Confidence Score
💾 Cache Performance
👆
Navigate to the "Reasoning Workspace" tab to get started!
""" @staticmethod def get_system_info_html(reasoner: AdvancedReasoner) -> str: """ â„šī¸ GENERATE SYSTEM INFO HTML """ return f""" **Session ID:** `{reasoner.session_id}` **Environment:** `{AppConfig.ENV}` **Cache Size:** {AppConfig.CACHE_SIZE} entries **Cache TTL:** {AppConfig.CACHE_TTL}s **Rate Limit:** {AppConfig.RATE_LIMIT_REQUESTS} req/{AppConfig.RATE_LIMIT_WINDOW}s **Max History:** {AppConfig.MAX_HISTORY_LENGTH} messages **Available Models:** {len(ModelConfig)} models **Reasoning Modes:** {len(ReasoningMode)} modes """ @staticmethod def get_settings_table_html() -> str: """ âš™ī¸ GENERATE SETTINGS TABLE HTML """ return f""" | Setting | Value | |---------|-------| | **Environment** | `{AppConfig.ENV}` | | **Debug Mode** | `{AppConfig.DEBUG}` | | **Max History Length** | {AppConfig.MAX_HISTORY_LENGTH} messages | | **Max Conversation Storage** | {AppConfig.MAX_CONVERSATION_STORAGE} conversations | | **Cache Size** | {AppConfig.CACHE_SIZE} entries | | **Cache TTL** | {AppConfig.CACHE_TTL} seconds | | **Rate Limit** | {AppConfig.RATE_LIMIT_REQUESTS} requests per {AppConfig.RATE_LIMIT_WINDOW}s | | **Request Timeout** | {AppConfig.REQUEST_TIMEOUT} seconds | | **Max Retries** | {AppConfig.MAX_RETRIES} attempts | | **Export Directory** | `{AppConfig.EXPORT_DIR}` | | **Backup Directory** | `{AppConfig.BACKUP_DIR}` | | **Available Models** | {len(ModelConfig)} models | | **Reasoning Modes** | {len(ReasoningMode)} modes | """ @staticmethod def get_reasoning_mode_choices() -> list: """Get reasoning mode choices""" return [mode.value for mode in ReasoningMode] @staticmethod def get_prompt_template_choices() -> list: """Get prompt template choices""" return list(PromptEngine.TEMPLATES.keys()) @staticmethod def get_model_choices() -> list: """Get model choices""" return [m.model_id for m in ModelConfig]