feat(whisper): feed profile_terms into initial_prompt at decode time

Previously profile_terms only reached the LLM cleanup stage as the
dictionary_terms suffix. Whisper decoded without any vocabulary hint, so
domain names ('Wren', 'CORBEL') were misspelled on the first pass and the
LLM had to guess at the correction.

build_initial_prompt (src-tauri/src/commands/mod.rs) collapses caller /
profile / terms into a single Whisper prompt:
  caller_prompt > profile_prompt + "Vocabulary: <terms>." > None

transcribe_pcm, transcribe_file, and start_live_transcription_session all
route through the helper, so the three paths stay in lockstep.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-21 07:35:02 +01:00
parent d1eb56fac9
commit 92d96a0841
3 changed files with 109 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ use std::sync::Arc;
use tauri::Emitter;
use crate::commands::build_initial_prompt;
use crate::commands::models::{default_model_id_for_engine, ensure_model_loaded};
use crate::AppState;
use kon_ai_formatting::{post_process_segments, FormatMode, PostProcessOptions};
@@ -165,20 +166,14 @@ pub async fn transcribe_pcm(
.map(|t| t.term)
.collect();
let effective_prompt = if !initial_prompt.is_empty() {
initial_prompt
} else {
profile.initial_prompt.clone()
};
let engine = state.whisper_engine.clone();
let options = TranscriptionOptions {
language: Some(language),
initial_prompt: if effective_prompt.is_empty() {
None
} else {
Some(effective_prompt)
},
initial_prompt: build_initial_prompt(
&initial_prompt,
&profile.initial_prompt,
&profile_terms,
),
};
let timed = tokio::task::spawn_blocking(move || {
@@ -252,12 +247,6 @@ pub async fn transcribe_file(
.map(|t| t.term)
.collect();
let effective_prompt = if !initial_prompt.is_empty() {
initial_prompt
} else {
profile.initial_prompt.clone()
};
let engine_name = engine.unwrap_or_else(|| "whisper".to_string());
let model_id =
model_id.unwrap_or_else(|| default_model_id_for_engine(&engine_name).to_string());
@@ -266,11 +255,11 @@ pub async fn transcribe_file(
let engine = pick_engine(&state, &engine_name)?;
let options = TranscriptionOptions {
language: Some(language),
initial_prompt: if effective_prompt.is_empty() {
None
} else {
Some(effective_prompt)
},
initial_prompt: build_initial_prompt(
&initial_prompt,
&profile.initial_prompt,
&profile_terms,
),
};
let engine_name_for_worker = engine_name.clone();