diff --git a/apps/desktop/src/store/zustand/ai-task/task-configs/enhance-workflow.ts b/apps/desktop/src/store/zustand/ai-task/task-configs/enhance-workflow.ts index d7640a9cd3..8ccdd48b50 100644 --- a/apps/desktop/src/store/zustand/ai-task/task-configs/enhance-workflow.ts +++ b/apps/desktop/src/store/zustand/ai-task/task-configs/enhance-workflow.ts @@ -143,7 +143,7 @@ async function generateTemplateIfNeeded(params: { model, schema, signal, - prompt: createTemplatePrompt(userPrompt, schema), + prompt: createTemplatePrompt(userPrompt, schema, args.language), }); if (!result) { @@ -162,11 +162,16 @@ async function generateTemplateIfNeeded(params: { function createTemplatePrompt( userPrompt: string, schema: z.ZodObject, + language: string | null, ): string { + const languageInstruction = language + ? `\n IMPORTANT: Generate all section titles in ${language} language.` + : ""; + return `Analyze this meeting content and suggest appropriate section headings for a comprehensive summary. The sections should cover the main themes and topics discussed. Generate around 5-7 sections based on the content depth. - Give me in bullet points. + Give me in bullet points.${languageInstruction} Content: --- @@ -237,7 +242,7 @@ async function* generateSummary(params: { onProgress({ type: "generating" }); - const validator = createValidator(args.template); + const validator = createValidator(args.template, args.language); yield* withEarlyValidationRetry( (retrySignal, { previousFeedback }) => { @@ -285,17 +290,24 @@ IMPORTANT: Previous attempt failed. ${previousFeedback}`; ); } -function createValidator(template: EnhanceTemplate | null): EarlyValidatorFn { +function createValidator( + template: EnhanceTemplate | null, + language: string | null, +): EarlyValidatorFn { + const isNonEnglish = + language != null && language !== "en" && !language.startsWith("en-"); + return (textSoFar: string) => { const normalized = textSoFar.trim(); - if (!template?.sections || template.sections.length === 0) { - if (!normalized.startsWith("# ")) { - const feedback = - "Output must start with a markdown h1 heading (# Title)."; - return { valid: false, feedback }; - } + if (!normalized.startsWith("# ")) { + return { + valid: false, + feedback: "Output must start with a markdown h1 heading (# Title).", + }; + } + if (isNonEnglish || !template?.sections || template.sections.length === 0) { return { valid: true }; } diff --git a/crates/template-app/assets/enhance.system.md.jinja b/crates/template-app/assets/enhance.system.md.jinja index d7c468090a..08d1eb0d41 100644 --- a/crates/template-app/assets/enhance.system.md.jinja +++ b/crates/template-app/assets/enhance.system.md.jinja @@ -34,6 +34,7 @@ You are an expert at creating structured, comprehensive meeting summaries in {{ - Pay close attention to emphasized text in raw notes. Users highlight information using four styles: bold(**text**), italic(_text_), underline(text), strikethrough(~~text~~). - Recognize H3 headers (### Header) in raw notes—these indicate highly important topics that the user wants to retain no matter what. {% if !(language|is_english) %} +- Section headings must be written entirely in {{ language | language }}. Do not include the original English title. For example, if in Korean, use "재무 및 운영 현황" instead of "Company Performance - 재무 및 운영 현황". - Keep technical terms (e.g., API, SDK, frontend, backend) and globally recognized product names (e.g., React, Vue.js, Django) in English. - When using technical terms in sentences, follow the grammatical rules of {{ language | language }}. {% endif %}