Files
Momento/memento-note/lib/ai/memory-echo-i18n.ts
Antigravity 30da592ba2
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 7m3s
CI / Deploy production (on server) (push) Successful in 23s
feat(dashboard): tableau de bord Second Brain configurable avec chargement progressif
Briefing granulaire, pistes rapides puis enrichissement async, layout persisté v5,
suggestions agents, intégration Gmail et navigation sidebar alignée sur /home.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 16:50:53 +00:00

117 lines
4.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { SupportedLanguage } from '@/lib/i18n/load-translations'
/** Texte de secours quand le LLM ne renvoie rien — une entrée par locale supportée. */
export const MEMORY_ECHO_INSIGHT_FALLBACKS: Record<SupportedLanguage, string> = {
en: 'These notes appear to be semantically related.',
fr: 'Ces notes semblent sémantiquement liées.',
es: 'Estas notas parecen estar relacionadas semánticamente.',
de: 'Diese Notizen scheinen semantisch miteinander verbunden zu sein.',
it: 'Queste note sembrano semanticamente collegate.',
pt: 'Estas notas parecem estar semanticamente relacionadas.',
nl: 'Deze notities lijken semantisch met elkaar verbonden.',
pl: 'Te notatki wydają się semantycznie powiązane.',
ru: 'Эти заметки кажутся семантическement связанными.',
zh: '这些笔记在语义上似乎相关。',
ja: 'これらのノートは意味的に関連しているようです。',
ko: '이 노트들은 의미적으로 관련된 것으로 보입니다.',
ar: 'يبدو أن هذه الملاحظات مرتبطة دلاليًا.',
fa: 'این یادداشت‌ها از نظر معنایی به هم مرتبط به نظر می‌رسند.',
hi: 'ये नोट्स अर्थ के हिसाब से जुड़े हुए लगते हैं।',
}
/** Anciens insights stockés en anglais — à remapper côté UI. */
export const MEMORY_ECHO_LEGACY_EN_FALLBACKS = new Set([
'These notes appear to be semantically related.',
])
const PROMPT_LANGUAGE_LABEL: Record<SupportedLanguage, string> = {
en: 'English',
fr: 'French',
es: 'Spanish',
de: 'German',
it: 'Italian',
pt: 'Portuguese',
nl: 'Dutch',
pl: 'Polish',
ru: 'Russian',
zh: 'Chinese',
ja: 'Japanese',
ko: 'Korean',
ar: 'Arabic',
fa: 'Persian',
hi: 'Hindi',
}
const UNTITLED_NOTE: Record<SupportedLanguage, string> = {
en: 'Untitled note',
fr: 'Note sans titre',
es: 'Nota sin título',
de: 'Unbenannte Notiz',
it: 'Nota senza titolo',
pt: 'Nota sem título',
nl: 'Naamloze notitie',
pl: 'Notatka bez tytułu',
ru: 'Без названия',
zh: '无标题笔记',
ja: '無題のノート',
ko: '제목 없는 노트',
ar: 'ملاحظة بدون عنوان',
fa: 'یادداشت بدون عنوان',
hi: 'शीर्षक रहित नोट',
}
export function getMemoryEchoInsightFallback(language: SupportedLanguage): string {
return MEMORY_ECHO_INSIGHT_FALLBACKS[language] ?? MEMORY_ECHO_INSIGHT_FALLBACKS.en
}
export function getUntitledNoteLabel(language: SupportedLanguage): string {
return UNTITLED_NOTE[language] ?? UNTITLED_NOTE.en
}
export function buildMemoryEchoInsightPrompt(
language: SupportedLanguage,
note1Title: string | null,
excerpt1: string,
note2Title: string | null,
excerpt2: string,
): string {
const untitled = getUntitledNoteLabel(language)
const note1Desc = note1Title || untitled
const note2Desc = note2Title || untitled
const langLabel = PROMPT_LANGUAGE_LABEL[language] ?? 'English'
if (language === 'fa' || language === 'ar') {
return `تو یک دستیار هستی که ارتباط بین یادداشت‌ها را تحلیل می‌کنی.
یادداشت ۱: «${note1Desc}»
متن: ${excerpt1}
یادداشت ۲: «${note2Desc}»
متن: ${excerpt2}
در یک جمله کوتاه (حداکثر ۱۵ کلمه) به ${language === 'fa' ? 'فارسی' : 'العربية'} توضیح بده چرا این دو یادداشت به هم مرتبط‌اند. فقط رابطه معنایی را بگو.`
}
if (language === 'fr') {
return `Tu analyses les connexions entre notes.
Note 1 : « ${note1Desc} »
Contenu : ${excerpt1}
Note 2 : « ${note2Desc} »
Contenu : ${excerpt2}
En une phrase courte (15 mots max), en français, explique pourquoi ces notes sont liées. Concentre-toi sur le lien sémantique.`
}
return `You analyze connections between notes.
Note 1: "${note1Desc}"
Content: ${excerpt1}
Note 2: "${note2Desc}"
Content: ${excerpt2}
Reply in ${langLabel} only. One brief sentence (max 15 words) explaining the semantic relationship between these notes.`
}