feat: i18n full support, responsive UI, multi-model AI config, and bug fixes

Major Features:
- Internationalization (i18n) with auto-detection for ES/EN/PT
- Mobile-first responsive design for Studio and Experience
- Multi-model AI configuration (llama3.2:3b, qwen3.5:9b, gpt-oss:latest)
- Course language configuration (auto-detect or fixed per course)

Backend Changes:
- shared/common: ModelType enum for intelligent model selection
- LMS: log_ai_usage function migration (fix chat tutor 500 error)
- LMS/CMS: course language config fields (language_setting, fixed_language)
- LMS: /courses/{id}/language-config endpoint for language detection

Frontend Changes:
- Experience: Enhanced i18n with browser language detection
- Experience: Audio recording with HTTPS check and error handling
- Studio: Memory game with unique pair IDs and debug logging
- Studio: Expanded translations (250+ keys for ES, EN, PT)
- Both: Language selector in headers (mobile responsive)

Documentation:
- AI_MODELS_CONFIG.md: Multi-model configuration guide
- RESPONSIVIDAD_GUIA.md: Mobile-first design patterns
- I18N_RESPONSIVIDAD_IMPLEMENTACION.md: Implementation details
- DEBUG_AUDIO_RECORDING.md: Audio troubleshooting guide
- DEBUG_MEMORY_GAME.md: Memory game debugging steps

Bug Fixes:
- Fix chat tutor 500 error (missing log_ai_usage function)
- Fix audio recording (HTTPS check, browser compatibility)
- Fix memory game pair IDs (unique ID generation)
- Fix HotspotBlock TypeScript errors

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-03-23 12:24:22 -03:00
parent 0598fc4865
commit 2ff06ee7ae
26 changed files with 2993 additions and 124 deletions
+76
View File
@@ -13,6 +13,59 @@ pub const DEFAULT_OLLAMA_URL: &str = "http://localhost:11434";
/// Embedding dimensions for nomic-embed-text
pub const EMBEDDING_DIMENSIONS: usize = 768;
/// Model selection for different use cases
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModelType {
/// Fast conversational AI (chat, tutor, Q&A)
Chat,
/// Complex reasoning (analysis, recommendations, feedback)
Complex,
/// Advanced tasks (course generation, detailed analysis)
Advanced,
/// Embedding generation
Embedding,
}
impl ModelType {
/// Get the model name for this type from environment
pub fn get_model(&self) -> String {
match self {
ModelType::Chat => {
std::env::var("LOCAL_LLM_MODEL").unwrap_or_else(|_| "llama3.2:3b".to_string())
}
ModelType::Complex => {
std::env::var("LOCAL_LLM_MODEL_COMPLEX").unwrap_or_else(|_| "qwen3.5:9b".to_string())
}
ModelType::Advanced => {
std::env::var("LOCAL_LLM_MODEL_ADVANCED").unwrap_or_else(|_| "gpt-oss:latest".to_string())
}
ModelType::Embedding => {
std::env::var("EMBEDDING_MODEL").unwrap_or_else(|_| "nomic-embed-text".to_string())
}
}
}
/// Get recommended temperature for this model type
pub fn get_temperature(&self) -> f32 {
match self {
ModelType::Chat => 0.7, // Balanced creativity/accuracy
ModelType::Complex => 0.5, // More focused reasoning
ModelType::Advanced => 0.6, // Balanced for analysis
ModelType::Embedding => 0.0, // Deterministic for embeddings
}
}
/// Get max tokens for this model type
pub fn get_max_tokens(&self) -> u32 {
match self {
ModelType::Chat => 1024,
ModelType::Complex => 2048,
ModelType::Advanced => 4096,
ModelType::Embedding => 0, // Not applicable
}
}
}
#[derive(Error, Debug)]
pub enum AiError {
#[error("Ollama request failed: {0}")]
@@ -40,6 +93,29 @@ pub fn get_embedding_model() -> String {
std::env::var("EMBEDDING_MODEL").unwrap_or_else(|_| DEFAULT_EMBEDDING_MODEL.to_string())
}
/// Get the best model for a specific task
pub fn get_model_for_task(task: &str) -> String {
// Task-based model selection
match task.to_lowercase().as_str() {
t if t.contains("chat") || t.contains("tutor") || t.contains("conversation") => {
ModelType::Chat.get_model()
}
t if t.contains("quiz") || t.contains("question") || t.contains("assessment") => {
ModelType::Complex.get_model()
}
t if t.contains("course") || t.contains("curriculum") || t.contains("syllabus") => {
ModelType::Advanced.get_model()
}
t if t.contains("feedback") || t.contains("recommendation") || t.contains("analysis") => {
ModelType::Complex.get_model()
}
t if t.contains("transcript") || t.contains("summary") => {
ModelType::Chat.get_model()
}
_ => ModelType::Chat.get_model(),
}
}
/// Create a reqwest client that accepts invalid certificates (for dev with self-signed certs)
fn create_insecure_client() -> Result<reqwest::Client, AiError> {
reqwest::Client::builder()