refactor: update prompt formatting to use system instruction tags and explicit user markers for improved model reasoning

This commit is contained in:
CJACK
2026-03-29 16:40:44 +08:00
parent 1d6a8e7008
commit 883607ac87

View File

@@ -42,12 +42,15 @@ func MessagesPrepare(messages []map[string]any) string {
} else { } else {
parts = append(parts, m.Text) parts = append(parts, m.Text)
} }
case "user", "system": case "system":
if i > 0 { // Clear system boundary improves R1 and V3 context understanding significantly
parts = append(parts, "<User>"+m.Text) if strings.TrimSpace(m.Text) != "" {
} else { parts = append(parts, "<system_instructions>\n"+strings.TrimSpace(m.Text)+"\n</system_instructions>\n\n")
parts = append(parts, m.Text)
} }
case "user":
// Always prepend <User> to user messages. DeepSeek R1 reasoning triggers best
// and aligns context perfectly when the user turn is explicitly marked.
parts = append(parts, "<User>"+m.Text)
default: default:
parts = append(parts, m.Text) parts = append(parts, m.Text)
} }