Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Move admin default initial prompt and hotwords into Default Prompts tab with a dedicated editor instead of the raw System Settings list
Murtaza Nasir4679acc3ab4a
diff --git a/static/locales/de.json b/static/locales/de.jsonindex 6a6a5644..e07bb086 100644--- a/static/locales/de.json+++ b/static/locales/de.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "Der Vektorspeicher ist auf dem neuesten Stand.","viewFullPromptStructure": "Vollständige LLM-Prompt-Struktur anzeigen","warning": "Warnung",- "yes": "Ja"+ "yes": "Ja",+ "defaultTranscriptionHints": "Standard-Transkriptionshinweise",+ "defaultTranscriptionHintsInfo": "Globaler Initial-Prompt und Hotwords, die bei jeder Transkription angewendet werden, wenn ein Benutzer keine eigenen festgelegt hat. Persönliche Werte der Benutzer haben immer Vorrang.",+ "defaultInitialPromptLabel": "Standard-Initial-Prompt",+ "defaultInitialPromptDesc": "Wird an die Transkriptions-Engine gesendet, um die Erkennung zu steuern (z. B. erwartetes Thema oder Vokabular).",+ "defaultHotwordsLabel": "Standard-Hotwords",+ "defaultHotwordsDesc": "Durch Kommas getrennte Wörter, um die Erkennung domänenspezifischer Begriffe zu verbessern."},"apiTokens": {"activeTokens": "Aktive Token",diff --git a/static/locales/en.json b/static/locales/en.jsonindex 6758f07c..9c850fdb 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "The vector store is up to date.","viewFullPromptStructure": "View Full LLM Prompt Structure","warning": "warning",- "yes": "Yes"+ "yes": "Yes",+ "defaultTranscriptionHints": "Default Transcription Hints",+ "defaultTranscriptionHintsInfo": "Global initial prompt and hotwords applied to every transcription when a user has not set their own. Users' personal values always take precedence.",+ "defaultInitialPromptLabel": "Default Initial Prompt",+ "defaultInitialPromptDesc": "Sent to the transcription engine to steer recognition (for example, the expected topic or vocabulary).",+ "defaultHotwordsLabel": "Default Hotwords",+ "defaultHotwordsDesc": "Comma-separated words to bias recognition of domain-specific terms."},"apiTokens": {"activeTokens": "Active Tokens",diff --git a/static/locales/es.json b/static/locales/es.jsonindex 2d98b544..a385b7bc 100644--- a/static/locales/es.json+++ b/static/locales/es.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "El almacén de vectores está actualizado.","viewFullPromptStructure": "Ver Estructura Completa del Prompt LLM","warning": "advertencia",- "yes": "Sí"+ "yes": "Sí",+ "defaultTranscriptionHints": "Sugerencias de transcripción predeterminadas",+ "defaultTranscriptionHintsInfo": "Prompt inicial y palabras clave globales aplicados a cada transcripción cuando un usuario no ha definido los suyos. Los valores personales de los usuarios siempre tienen prioridad.",+ "defaultInitialPromptLabel": "Prompt inicial predeterminado",+ "defaultInitialPromptDesc": "Se envía al motor de transcripción para guiar el reconocimiento (por ejemplo, el tema o vocabulario esperado).",+ "defaultHotwordsLabel": "Palabras clave predeterminadas",+ "defaultHotwordsDesc": "Palabras separadas por comas para favorecer el reconocimiento de términos específicos del dominio."},"apiTokens": {"activeTokens": "Tokens activos",diff --git a/static/locales/fr.json b/static/locales/fr.jsonindex 41790d2f..7083e1e9 100644--- a/static/locales/fr.json+++ b/static/locales/fr.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "Le magasin de vecteurs est à jour.","viewFullPromptStructure": "Voir la Structure Complète de l'Invite LLM","warning": "avertissement",- "yes": "Oui"+ "yes": "Oui",+ "defaultTranscriptionHints": "Indications de transcription par défaut",+ "defaultTranscriptionHintsInfo": "Prompt initial et mots-clés globaux appliqués à chaque transcription lorsque l'utilisateur n'a pas défini les siens. Les valeurs personnelles des utilisateurs sont toujours prioritaires.",+ "defaultInitialPromptLabel": "Prompt initial par défaut",+ "defaultInitialPromptDesc": "Envoyé au moteur de transcription pour orienter la reconnaissance (par exemple le sujet ou le vocabulaire attendu).",+ "defaultHotwordsLabel": "Mots-clés par défaut",+ "defaultHotwordsDesc": "Mots séparés par des virgules pour favoriser la reconnaissance de termes spécifiques au domaine."},"apiTokens": {"activeTokens": "Jetons actifs",diff --git a/static/locales/pt-BR.json b/static/locales/pt-BR.jsonindex f20f28a4..5cb3a62d 100644--- a/static/locales/pt-BR.json+++ b/static/locales/pt-BR.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "O armazenamento vetorial está atualizado.","viewFullPromptStructure": "Ver Estrutura Completa da Instrução do LLM","warning": "aviso",- "yes": "Sim"+ "yes": "Sim",+ "defaultTranscriptionHints": "Dicas de transcrição padrão",+ "defaultTranscriptionHintsInfo": "Prompt inicial e hotwords globais aplicados a cada transcrição quando o usuário não definiu os seus. Os valores pessoais dos usuários sempre têm prioridade.",+ "defaultInitialPromptLabel": "Prompt inicial padrão",+ "defaultInitialPromptDesc": "Enviado ao mecanismo de transcrição para orientar o reconhecimento (por exemplo, o tema ou vocabulário esperado).",+ "defaultHotwordsLabel": "Hotwords padrão",+ "defaultHotwordsDesc": "Palavras separadas por vírgulas para favorecer o reconhecimento de termos específicos do domínio."},"apiTokens": {"activeTokens": "Tokens Ativos",diff --git a/static/locales/ru.json b/static/locales/ru.jsonindex 747a62ab..32cf2c66 100644--- a/static/locales/ru.json+++ b/static/locales/ru.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "Векторное хранилище актуально.","viewFullPromptStructure": "Показать полную структуру запросов LLM","warning": "предупреждение",- "yes": "Да"+ "yes": "Да",+ "defaultTranscriptionHints": "Подсказки транскрипции по умолчанию",+ "defaultTranscriptionHintsInfo": "Глобальный начальный промпт и ключевые слова, применяемые к каждой транскрипции, когда пользователь не задал свои. Личные значения пользователей всегда имеют приоритет.",+ "defaultInitialPromptLabel": "Начальный промпт по умолчанию",+ "defaultInitialPromptDesc": "Отправляется в движок транскрипции для управления распознаванием (например, ожидаемая тема или лексика).",+ "defaultHotwordsLabel": "Ключевые слова по умолчанию",+ "defaultHotwordsDesc": "Слова через запятую для улучшения распознавания узкоспециальных терминов."},"apiTokens": {"activeTokens": "Активные токены",diff --git a/static/locales/zh.json b/static/locales/zh.jsonindex dab5b33b..d672ca7a 100644--- a/static/locales/zh.json+++ b/static/locales/zh.json@@ -288,7 +288,13 @@"vectorStoreUpToDate": "向量存储是最新的","viewFullPromptStructure": "查看完整的 LLM 提示结构","warning": "警告",- "yes": "是"+ "yes": "是",+ "defaultTranscriptionHints": "默认转录提示",+ "defaultTranscriptionHintsInfo": "当用户未设置自己的值时,应用于每次转录的全局初始提示和热词。用户的个人设置始终优先。",+ "defaultInitialPromptLabel": "默认初始提示",+ "defaultInitialPromptDesc": "发送给转录引擎以引导识别(例如预期的主题或词汇)。",+ "defaultHotwordsLabel": "默认热词",+ "defaultHotwordsDesc": "用逗号分隔的词语,用于提高对特定领域术语的识别。"},"apiTokens": {"activeTokens": "活跃令牌",diff --git a/templates/admin.html b/templates/admin.htmlindex 8dbb6dde..22acbb86 100644--- a/templates/admin.html+++ b/templates/admin.html@@ -902,13 +902,60 @@</div><div v-if="promptSaveMessage" class="mt-4">- <div :class="promptSaveError ? 'bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]' : 'bg-[var(--bg-success-light)] text-[var(--text-success-strong)]'"+ <div :class="promptSaveError ? 'bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]' : 'bg-[var(--bg-success-light)] text-[var(--text-success-strong)]'"class="p-3 rounded-md text-sm">${ promptSaveMessage }</div></div></div>-++ <!-- Default transcription hints: global initial prompt + hotwords applied+ when a user has not set their own. Authoritative editor for the+ admin_default_initial_prompt / admin_default_hotwords settings+ (hidden from the raw System Settings list to avoid a duplicate editor). -->+ <div class="mt-6 bg-[var(--bg-tertiary)] p-6 rounded-lg border border-[var(--border-primary)]">+ <h4 class="text-md font-medium text-[var(--text-secondary)] mb-1">${t('adminDashboard.defaultTranscriptionHints')}</h4>+ <p class="text-sm text-[var(--text-muted)] mb-4">${t('adminDashboard.defaultTranscriptionHintsInfo')}</p>++ <div class="mb-4">+ <label class="block text-sm font-medium text-[var(--text-secondary)] mb-2">${t('adminDashboard.defaultInitialPromptLabel')}</label>+ <p class="text-sm text-[var(--text-muted)] mb-3">${t('adminDashboard.defaultInitialPromptDesc')}</p>+ <textarea+ v-model="defaultInitialPrompt"+ rows="3"+ class="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-md focus:outline-none focus:ring-2 focus:ring-[var(--border-focus)] bg-[var(--bg-input)] text-[var(--text-primary)]"+ :placeholder="t('account.defaultInitialPromptPlaceholder')">+ </textarea>+ </div>++ <div class="mb-4">+ <label class="block text-sm font-medium text-[var(--text-secondary)] mb-2">${t('adminDashboard.defaultHotwordsLabel')}</label>+ <p class="text-sm text-[var(--text-muted)] mb-3">${t('adminDashboard.defaultHotwordsDesc')}</p>+ <input+ type="text"+ v-model="defaultHotwords"+ class="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-md focus:outline-none focus:ring-2 focus:ring-[var(--border-focus)] bg-[var(--bg-input)] text-[var(--text-primary)]"+ :placeholder="t('form.hotwordsPlaceholder')">+ </div>++ <div class="flex justify-end items-center">+ <button @click="saveDefaultHints"+ :disabled="isSavingHints"+ class="btn btn--primary">+ <i v-if="isSavingHints" class="fas fa-spinner fa-spin mr-2"></i>+ <i v-else class="fas fa-save mr-2"></i>+ ${ isSavingHints ? t('adminDashboard.saving') : t('buttons.saveChanges') }+ </button>+ </div>++ <div v-if="hintsSaveMessage" class="mt-4">+ <div :class="hintsSaveError ? 'bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]' : 'bg-[var(--bg-success-light)] text-[var(--text-success-strong)]'"+ class="p-3 rounded-md text-sm">+ ${ hintsSaveMessage }+ </div>+ </div>+ </div>+<div class="mt-6 bg-[var(--bg-tertiary)] p-6 rounded-lg border border-[var(--border-primary)]"><h4 class="text-md font-medium text-[var(--text-secondary)] mb-3">${t('adminDashboard.promptHierarchy')}</h4><p class="text-sm text-[var(--text-muted)] mb-3">@@ -2035,6 +2082,11 @@ Summarization Instructions:'transcription_models_visible_json','transcription_default_model','admin_default_summary_prompt',+ // Managed by the dedicated "Default transcription hints"+ // editor in the Default Prompts tab — hidden here so the+ // raw card isn't a redundant second editor.+ 'admin_default_initial_prompt',+ 'admin_default_hotwords',]);const displayedSettings = computed(() =>(settings.value || []).filter(s => !HIDDEN_SETTING_KEYS.has(s.key))@@ -2253,6 +2305,12 @@ Summarization Instructions:const promptSaveMessage = ref('');const promptSaveError = ref(false);const showFullPromptStructure = ref(false);+ // Default transcription hints (managed in the Default Prompts tab)+ const defaultInitialPrompt = ref('');+ const defaultHotwords = ref('');+ const isSavingHints = ref(false);+ const hintsSaveMessage = ref('');+ const hintsSaveError = ref(false);const originalDefaultPrompt = `Generate a comprehensive summary that includes the following sections:- **Key Issues Discussed**: A bulleted list of the main topics- **Key Decisions Made**: A bulleted list of any decisions reached@@ -3388,12 +3446,66 @@ Summarization Instructions:if (promptSetting) {defaultSummaryPrompt.value = promptSetting.value || '';}++ // Default transcription hints share this tab.+ const ipSetting = settingsData.find(s => s.key === 'admin_default_initial_prompt');+ defaultInitialPrompt.value = ipSetting ? (ipSetting.value || '') : '';+ const hwSetting = settingsData.find(s => s.key === 'admin_default_hotwords');+ defaultHotwords.value = hwSetting ? (hwSetting.value || '') : '';} catch (error) {console.error('Error loading default prompt:', error);promptSaveMessage.value = t('adminDashboard.errors.failedToLoadPrompt');promptSaveError.value = true;}};++ const saveDefaultHints = async () => {+ isSavingHints.value = true;+ hintsSaveMessage.value = '';+ hintsSaveError.value = false;++ const csrf = document.querySelector('meta[name="csrf-token"]').content;+ const putSetting = async (key, value, description) => {+ const response = await fetch('/admin/settings', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrf },+ body: JSON.stringify({ key, value, description, setting_type: 'string' })+ });+ if (!response.ok) throw new Error('Failed to save ' + key);+ };++ try {+ await putSetting(+ 'admin_default_initial_prompt',+ defaultInitialPrompt.value,+ 'Global initial prompt injected into all transcription requests. Applied when users have not set their own initial prompt.'+ );+ await putSetting(+ 'admin_default_hotwords',+ defaultHotwords.value,+ 'Global hotwords injected into all transcription requests. Comma-separated. Applied when users have not set their own hotwords.'+ );++ // Keep the cached settings list in sync so the hidden+ // raw cards don't show stale values if revisited.+ const sync = (key, value) => {+ const row = (settings.value || []).find(s => s.key === key);+ if (row) row.value = value;+ };+ sync('admin_default_initial_prompt', defaultInitialPrompt.value);+ sync('admin_default_hotwords', defaultHotwords.value);++ hintsSaveMessage.value = t('adminDashboard.promptSavedSuccessfully');+ hintsSaveError.value = false;+ setTimeout(() => { hintsSaveMessage.value = ''; }, 3000);+ } catch (error) {+ console.error('Error saving default hints:', error);+ hintsSaveMessage.value = t('adminDashboard.errors.failedToSavePrompt');+ hintsSaveError.value = true;+ } finally {+ isSavingHints.value = false;+ }+ };const saveDefaultPrompt = async () => {isSavingPrompt.value = true;@@ -3738,6 +3850,11 @@ Summarization Instructions:showFullPromptStructure,originalDefaultPrompt,formatPromptPreview,+ defaultInitialPrompt,+ defaultHotwords,+ isSavingHints,+ hintsSaveMessage,+ hintsSaveError,// ComputedfilteredUsers,@@ -3817,7 +3934,8 @@ Summarization Instructions:// Default Prompts methodsloadDefaultPrompt,saveDefaultPrompt,- resetDefaultPrompt+ resetDefaultPrompt,+ saveDefaultHints};},delimiters: ['${', '}'] // Use different delimiters to avoid conflict with Flask's Jinja2