From 42184708302a4fe99990692c20c8fd001f87f9e2 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Fri, 29 May 2026 13:13:28 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20g=C3=A9n=C3=A9ration=20slides=20dans=20l?= =?UTF-8?q?a=20langue=20de=20la=20note=20(15=20langues)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Récupère note.language (détecté automatiquement) depuis la DB - LANG_NAMES: mapping code → nom complet (fa→Persian, ar→Arabic, zh→Chinese...) - Injecte règle de langue absolue dans le prompt: tous les textes des slides doivent être dans la langue de la note - Fonctionnement pour les 15 locales du projet Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../lib/ai/services/agent-executor.service.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/memento-note/lib/ai/services/agent-executor.service.ts b/memento-note/lib/ai/services/agent-executor.service.ts index c189ac3..3ff7814 100644 --- a/memento-note/lib/ai/services/agent-executor.service.ts +++ b/memento-note/lib/ai/services/agent-executor.service.ts @@ -1286,13 +1286,13 @@ async function executeToolUseAgent( if (specificNoteIds.length > 0) { notes = await prisma.note.findMany({ where: { id: { in: specificNoteIds }, userId: agent.userId, isArchived: false, trashedAt: null }, - select: { id: true, title: true, content: true, createdAt: true } + select: { id: true, title: true, content: true, createdAt: true, language: true } }) } else if (agent.sourceNotebookId) { notes = await prisma.note.findMany({ where: { notebookId: agent.sourceNotebookId, userId: agent.userId, isArchived: false, trashedAt: null }, orderBy: { createdAt: 'desc' }, take: 15, - select: { id: true, title: true, content: true, createdAt: true } + select: { id: true, title: true, content: true, createdAt: true, language: true } }) } else { const notebooks = await prisma.notebook.findMany({ @@ -1305,13 +1305,25 @@ async function executeToolUseAgent( notes = await prisma.note.findMany({ where: { notebookId: best.id, userId: agent.userId, isArchived: false, trashedAt: null }, orderBy: { createdAt: 'desc' }, take: 15, - select: { id: true, title: true, content: true, createdAt: true } + select: { id: true, title: true, content: true, createdAt: true, language: true } }) } } - prompt = lang === 'fr' - ? `Crée une présentation professionnelle sur le sujet "${slideTopic}" en utilisant le contenu des notes ci-dessous. Appelle generate_slides avec un objet JSON structuré (title, theme, slides[]).` - : `Create a professional presentation about "${slideTopic}" using the content from the notes below. Call generate_slides with a structured JSON object (title, theme, slides[]).` + + // Detect content language — use note's detected language, fallback to user lang + const noteLanguage = notes[0]?.language || null + // Map language codes to full names for the prompt + const LANG_NAMES: Record = { + fr: 'French', en: 'English', es: 'Spanish', de: 'German', it: 'Italian', + pt: 'Portuguese', nl: 'Dutch', pl: 'Polish', ru: 'Russian', zh: 'Chinese', + ja: 'Japanese', ko: 'Korean', ar: 'Arabic', fa: 'Persian (Farsi)', hi: 'Hindi', + } + const contentLang = noteLanguage && LANG_NAMES[noteLanguage] + ? LANG_NAMES[noteLanguage] + : (lang === 'fr' ? 'French' : 'English') + + prompt = `Create a professional presentation using the content from the notes below. Call generate_slides with a structured JSON object (title, theme, slides[]).` + prompt += `\n\n⚠️ LANGUAGE RULE: ALL slide text (titles, bullets, labels, subtitles) MUST be written in ${contentLang}. Do NOT translate to another language.` if (notes.length > 0) { const notesContext = notes.map(n =>