fix: génération slides dans la langue de la note (15 langues)
Some checks failed
CI / Deploy production (on server) (push) Has been cancelled
CI / Lint, Unit Tests & Build (push) Has been cancelled

- 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>
This commit is contained in:
Antigravity
2026-05-29 13:13:28 +00:00
parent 6f8121e937
commit 4218470830

View File

@@ -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<string, string> = {
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 =>