UntilDot commited on
Commit
88896da
·
verified ·
1 Parent(s): 11cdaee

Update static/docs.js

Browse files
Files changed (1) hide show
  1. static/docs.js +137 -6
static/docs.js CHANGED
@@ -1,15 +1,146 @@
1
- // === Theme Toggle ===
2
  const themeToggle = document.getElementById('themeToggle');
3
  themeToggle.addEventListener('click', () => {
4
  document.documentElement.classList.toggle('dark');
5
  themeToggle.textContent = document.documentElement.classList.contains('dark') ? '🌙' : '☀️';
6
  });
7
 
8
- // === Language Toggle ===
9
  const langToggle = document.getElementById('langToggle');
10
- const en = document.getElementById('en');
11
- const es = document.getElementById('es');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  langToggle.addEventListener('click', () => {
13
- en.classList.toggle('hidden');
14
- es.classList.toggle('hidden');
15
  });
 
 
 
 
 
1
  const themeToggle = document.getElementById('themeToggle');
2
  themeToggle.addEventListener('click', () => {
3
  document.documentElement.classList.toggle('dark');
4
  themeToggle.textContent = document.documentElement.classList.contains('dark') ? '🌙' : '☀️';
5
  });
6
 
 
7
  const langToggle = document.getElementById('langToggle');
8
+ let currentLang = 'en';
9
+
10
+ const translations = {
11
+ en: {
12
+ title: "MoA Chat - Documentation",
13
+ what_is_title: "📖 What is MoA Chat?",
14
+ intro: "<strong>MoA Chat</strong> is a simple but powerful chat platform where multiple AI models answer the same question at the same time, and an aggregator model combines their outputs into one final answer.",
15
+ tech_1: "Built in <strong>Python 3</strong>.",
16
+ tech_2: "Web framework: <strong>Flask</strong>.",
17
+ tech_3: "Frontend: HTML, JavaScript, TailwindCSS (optionally removable).",
18
+ tech_4: "Designed to work <strong>first on Hugging Face Spaces</strong>, but can also be <strong>self-hosted</strong>.",
19
+ architecture_alt: "MoA Architecture",
20
+ features_title: "⚙️ Features",
21
+ feature_1: "Send your question once — multiple AI models answer simultaneously.",
22
+ feature_2: "Aggregator model (LLM-D) summarizes all responses.",
23
+ feature_3: "Fully configurable: choose which models you want to use.",
24
+ feature_4: "Modern minimal UI with light/dark theme toggle.",
25
+ feature_5: "Spanish/English documentation switch.",
26
+ feature_6: "<strong>Free models</strong> supported through <strong>OpenRouter</strong> and others.",
27
+ feature_7: "<strong>No API keys exposed</strong> in the frontend (safe backend request).",
28
+ self_host_title: "🛠️ Self Hosting",
29
+ self_host_intro: "You can clone the project like this:",
30
+ requirements_title: "Requirements:",
31
+ req_1: "Python 3.11+",
32
+ req_2: "Pip",
33
+ req_3: "Create a <code>.env</code> file and add your API keys.",
34
+ install_title: "Install dependencies:",
35
+ run_title: "Run locally:",
36
+ port_note: "Default port is <strong>7860</strong> (to match Hugging Face standard).",
37
+ docker_title: "🐳 Docker support:",
38
+ docker_intro: "Your repository includes a <code>Dockerfile</code> for easy containerization when you clone it. Here's the content:",
39
+ docker_alt_option: "Alternatively, you can manually create your own <code>Dockerfile</code> with the above content if you prefer to customize it.",
40
+ docker_build: "To build and run the Docker container after cloning the repository:",
41
+ docker_secrets_note: "Docker will NOT automatically inject secrets unless you:",
42
+ docker_secret_env: "Use a <code>.env</code> file with <code>--env-file .env</code>",
43
+ docker_secret_manual: "Manually use <code>-e VAR=VALUE</code> flags in <code>docker run</code>",
44
+ api_keys_title: "🔑 Environment Variables (Secrets)",
45
+ api_keys_intro: "To use this app, you must set your API keys in <strong>secrets</strong> or <strong>environment variables</strong>.",
46
+ api_keys_syntax: "Follow this syntax:",
47
+ api_keys_code: "OPENROUTER_API_KEY=your-openrouter-key\nTOGETHER_API_KEY=your-together-key\nGROK_API_KEY=your-grok-key\nGROQ_API_KEY=your-groq-key",
48
+ api_keys_location: "You can set these in:",
49
+ api_loc_1: "Hugging Face <strong>Secrets</strong> section (recommended if on Spaces)",
50
+ api_loc_2: "<code>.env</code> file (only for self-hosting)",
51
+ add_models_title: "🧩 How to Add More Models",
52
+ add_models_intro: "All models and providers are declared inside:",
53
+ add_models_structure: "The structure looks like this:",
54
+ add_models_steps_title: "<strong>To add a new model:</strong>",
55
+ add_step_1: "Find the right provider (OpenRouter, Together, Grok, Groq, etc).",
56
+ add_step_2: "Add its endpoint URL under \"providers\" if not already listed.",
57
+ add_step_3: "Add your model name under \"models\" section, linking it to the provider.",
58
+ add_models_note: "Make sure your environment variables (secrets) are correctly configured.",
59
+ license_title: "🏷️ Licensing",
60
+ license_text: "This project is licensed under <strong>Apache 2.0</strong> — You are free to use, modify, and distribute, even commercially.",
61
+
62
+ footer: "Made with ❤️ in Panamá<br>by UntilDot\n<div class=\"mt-2 flex justify-center\">\n <span class=\"mx-2\">✨</span>\n <span class=\"mx-2\">✨</span>\n</div>"
63
+ },
64
+ es: {
65
+ title: "MoA Chat - Documentación",
66
+ what_is_title: "📖 ¿Qué es MoA Chat?",
67
+ intro: "<strong>MoA Chat</strong> es una plataforma de chat simple pero poderosa donde múltiples modelos de IA responden la misma pregunta al mismo tiempo, y un modelo agregador combina sus resultados en una respuesta final.",
68
+ tech_1: "Construido en <strong>Python 3</strong>.",
69
+ tech_2: "Framework web: <strong>Flask</strong>.",
70
+ tech_3: "Frontend: HTML, JavaScript, TailwindCSS (opcionalmente removible).",
71
+ tech_4: "Diseñado para funcionar <strong>primero en Hugging Face Spaces</strong>, pero también puede ser <strong>autohospedado</strong>.",
72
+ architecture_alt: "Arquitectura MoA",
73
+ features_title: "⚙️ Características",
74
+ feature_1: "Envía tu pregunta una vez — múltiples modelos de IA responden simultáneamente.",
75
+ feature_2: "Modelo agregador (LLM-D) resume todas las respuestas.",
76
+ feature_3: "Completamente configurable: elige qué modelos deseas usar.",
77
+ feature_4: "Interfaz de usuario minimalista moderna con cambio de tema claro/oscuro.",
78
+ feature_5: "Cambio de documentación entre español/inglés.",
79
+ feature_6: "<strong>Modelos gratuitos</strong> soportados a través de <strong>OpenRouter</strong> y otros.",
80
+ feature_7: "<strong>Sin claves API expuestas</strong> en el frontend (solicitud segura al backend).",
81
+ self_host_title: "🛠️ Autohospedaje",
82
+ self_host_intro: "Puedes clonar el proyecto así:",
83
+ requirements_title: "Requisitos:",
84
+ req_1: "Python 3.11+",
85
+ req_2: "Pip",
86
+ req_3: "Crea un archivo <code>.env</code> y agrega tus claves API.",
87
+ install_title: "Instalar dependencias:",
88
+ run_title: "Ejecutar localmente:",
89
+ port_note: "El puerto predeterminado es <strong>7860</strong> (para coincidir con el estándar de Hugging Face).",
90
+ docker_title: "🐳 Soporte para Docker:",
91
+ docker_intro: "Tu repositorio incluye un <code>Dockerfile</code> para una fácil containerización cuando lo clonas. Aquí está el contenido:",
92
+ docker_alt_option: "Alternativamente, puedes crear manualmente tu propio <code>Dockerfile</code> con el contenido anterior si prefieres personalizarlo.",
93
+ docker_build: "Para construir y ejecutar el contenedor Docker después de clonar el repositorio:",
94
+ docker_secrets_note: "Docker NO inyectará automáticamente los secretos a menos que:",
95
+ docker_secret_env: "Uses un archivo <code>.env</code> con <code>--env-file .env</code>",
96
+ docker_secret_manual: "Uses manualmente banderas <code>-e VAR=VALUE</code> en <code>docker run</code>",
97
+ api_keys_title: "🔑 Variables de Entorno (Secretos)",
98
+ api_keys_intro: "Para usar esta aplicación, debes configurar tus claves API en <strong>secretos</strong> o <strong>variables de entorno</strong>.",
99
+ api_keys_syntax: "Sigue esta sintaxis:",
100
+ api_keys_code: "OPENROUTER_API_KEY=tu-clave-openrouter\nTOGETHER_API_KEY=tu-clave-together\nGROK_API_KEY=tu-clave-grok\nGROQ_API_KEY=tu-clave-groq",
101
+ api_keys_location: "Puedes configurarlas en:",
102
+ api_loc_1: "Sección de <strong>Secretos</strong> de Hugging Face (recomendado si estás en Spaces)",
103
+ api_loc_2: "Archivo <code>.env</code> (solo para autohospedaje)",
104
+ add_models_title: "🧩 Cómo Agregar Más Modelos",
105
+ add_models_intro: "Todos los modelos y proveedores se declaran dentro de:",
106
+ add_models_structure: "La estructura se ve así:",
107
+ add_models_steps_title: "<strong>Para agregar un nuevo modelo:</strong>",
108
+ add_step_1: "Encuentra el proveedor adecuado (OpenRouter, Together, Grok, Groq, etc).",
109
+ add_step_2: "Agrega su URL de endpoint bajo \"providers\" si no está ya listado.",
110
+ add_step_3: "Agrega el nombre de tu modelo bajo la sección \"models\", vinculándolo al proveedor.",
111
+ add_models_note: "Asegúrate de que tus variables de entorno (secretos) estén correctamente configuradas.",
112
+ license_title: "🏷️ Licenciamiento",
113
+ license_text: "Este proyecto está licenciado bajo <strong>Apache 2.0</strong> — Eres libre de usar, modificar y distribuir, incluso comercialmente.",
114
+
115
+ footer: "Hecho con ❤️ en Panamá<br>por UntilDot\n<div class=\"mt-2 flex justify-center\">\n <span class=\"mx-2\">✨</span>\n <span class=\"mx-2\">✨</span>\n</div>"
116
+ }
117
+ };
118
+
119
+ function updateLanguage(lang) {
120
+ document.querySelectorAll('[data-i18n]').forEach(element => {
121
+ const key = element.getAttribute('data-i18n');
122
+ if (translations[lang][key]) {
123
+ element.innerHTML = translations[lang][key];
124
+ }
125
+ });
126
+ document.querySelectorAll('[data-i18n-alt]').forEach(element => {
127
+ const key = element.getAttribute('data-i18n-alt');
128
+ if (translations[lang][key]) {
129
+ element.setAttribute('alt', translations[lang][key]);
130
+ }
131
+ });
132
+ document.querySelectorAll('code[data-i18n]').forEach(element => {
133
+ const key = element.getAttribute('data-i18n');
134
+ if (translations[lang][key]) {
135
+ element.textContent = translations[lang][key];
136
+ }
137
+ });
138
+ }
139
+
140
  langToggle.addEventListener('click', () => {
141
+ currentLang = currentLang === 'en' ? 'es' : 'en';
142
+ updateLanguage(currentLang);
143
  });
144
+
145
+ // Initialize language on load
146
+ updateLanguage(currentLang);