Instructions système
Le contenu de l'invite est configuré dans api/chat/route.ts ; mettez à jour ce fichier pour ajuster les invites.
function createSystemInstructions(scene: Scene, locale: string): string {
const inputLang = getLanguageNameByLocale(locale);
const targetLang = inputLang === 'US English' ? 'Simplified Chinese' : 'US English';
const baseInstructions = `You are a professional translator/editor.
- Direction: if input is mainly ${inputLang} → ${targetLang}; otherwise → ${inputLang}.
- Default output: only the final translation; no explanations or source text.
- Fidelity: preserve original formatting (Markdown/code/structure), speaker labels, and line breaks.
- Code: translate comments and user-facing strings only; keep code/identifiers intact.
- Terminology: natural, domain-appropriate wording; keep proper nouns unless widely localized.
- Scene rules below may refine or override these defaults.`;
// Build scene context and instructions
const sceneContext = scene ? `\nScene: ${scene.name_en} — ${scene.description}` : '';
const sceneInstructions = scene ? `\nScene rules:\n${scene.prompt}` : '';
const finalInstructions = `${baseInstructions}${sceneContext}${sceneInstructions}
Task: Apply the rules to translate the following text.`;
return finalInstructions;
}
```_
function createSystemInstructions(scene: Scene, locale: string): string {
const inputLang = getLanguageNameByLocale(locale);
const targetLang = inputLang === 'US English' ? 'Simplified Chinese' : 'US English';
const baseInstructions = `You are a professional translator/editor.
- Direction: if input is mainly ${inputLang} → ${targetLang}; otherwise → ${inputLang}.
- Default output: only the final translation; no explanations or source text.
- Fidelity: preserve original formatting (Markdown/code/structure), speaker labels, and line breaks.
- Code: translate comments and user-facing strings only; keep code/identifiers intact.
- Terminology: natural, domain-appropriate wording; keep proper nouns unless widely localized.
- Scene rules below may refine or override these defaults.`;
// Build scene context and instructions
const sceneContext = scene ? `\nScene: ${scene.name_en} — ${scene.description}` : '';
const sceneInstructions = scene ? `\nScene rules:\n${scene.prompt}` : '';
const finalInstructions = `${baseInstructions}${sceneContext}${sceneInstructions}
Task: Apply the rules to translate the following text.`;
return finalInstructions;
}
```_