"""
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 """
"""
@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 """
đ
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]