feat(tenant): enforce English output for en-US template generation
When the article locale is en-US, Chinese prompt templates could leak Chinese wording into generated titles, outlines, and article bodies. Add high-priority language-consistency guards so the model treats the Chinese template text as internal instructions and emits English only. - Append per-artifact locale guards (analyze/title/outline) in template assist prompts and an article-body guard in the generation prompt, only when locale is en-US - Reinforce locale consistency in the title/outline runtime prompts and drop retained images from the rewrite prompt - Cover the new guards with unit tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,27 @@ func buildGenerationPrompt(
|
||||
sections = append(sections, prompts.GenerationLengthGuidanceHeading()+"\n"+lengthGuidance)
|
||||
}
|
||||
|
||||
if localeGuard := buildGenerationLocaleGuard(params); localeGuard != "" {
|
||||
sections = append(sections, localeGuard)
|
||||
}
|
||||
|
||||
return strings.Join(sections, "\n\n")
|
||||
}
|
||||
|
||||
func buildGenerationLocaleGuard(params map[string]interface{}) string {
|
||||
if strings.TrimSpace(stringValue(params["locale"])) != "en-US" {
|
||||
return ""
|
||||
}
|
||||
|
||||
return strings.Join([]string{
|
||||
"High-priority language consistency requirement:",
|
||||
"- The final article output must be entirely in natural, professional English.",
|
||||
"- Treat any Chinese template text, Chinese examples, Chinese section names, or Chinese disclaimers as internal instructions only; translate or adapt them into English before writing.",
|
||||
"- Do not output Chinese prose, Chinese headings, Chinese punctuation patterns, or Chinese-only required sentences unless they are official brand, company, product, or legal names that must remain unchanged.",
|
||||
"- If title, article_outline, outline_sections, key_points, or knowledge snippets contain Chinese, rewrite the generated article content in English while preserving the intended meaning.",
|
||||
}, "\n")
|
||||
}
|
||||
|
||||
func buildGenerationKnowledgeQuery(templateKey, templateName string, params map[string]interface{}) string {
|
||||
if len(params) == 0 {
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user