This commit is contained in:
greeneclipse committed 2026-11-11 20:24:59 +01:00
1 parent eefb7e2b75
commit 41f1a7dbe4
2 files changed
+58 -2

No files matched your search

@@ -0,0 +1,38 @@
package processing
import (
"strings"
"testing"
)
func TestAppendDescriptionRichnessOverrideIsIdempotent(t *testing.T) {
once := AppendDescriptionRichnessOverride("base system")
if !strings.HasPrefix(once, "base system\n") || !strings.Contains(once, "Description depth (platform rule") {
t.Fatalf("override not appended: %q", once)
}
if twice := AppendDescriptionRichnessOverride(once); twice != once {
t.Fatal("override appended twice")
}
if AppendDescriptionRichnessOverride("") != descriptionRichnessOverride {
t.Fatal("empty system should become the override alone")
}
}
func TestResolveProductPromptTemplatesAddsRichnessOverride(t *testing.T) {
cases := map[string]ProductInput{
"category prompt": {
CategoryEnhancePrompt: "Opis: {{description}} {{attrs}}",
CategoryUniqueID: "televizorji",
},
"no prompt": {},
}
for name, in := range cases {
sys, _ := resolveProductPromptTemplates(in)
if !strings.Contains(sys, "Description depth (platform rule") {
t.Errorf("%s: system prompt lacks richness override", name)
}
if !strings.Contains(sys, "never") && !strings.Contains(sys, "Do not invent") {
t.Errorf("%s: override must keep the no-invention rule", name)
}
}
}
+20 -2
View File
@@ -26,7 +26,7 @@ func resolveProductPromptTemplates(in ProductInput) (systemTpl, userTpl string)
}
allowed := enhanceAllowedAttrKeys(in, in.CategoryUniqueID)
userTpl = AppendAttributeConstraints(userTpl, allowed, in.TitleTemplate)
return systemTpl, userTpl
return AppendDescriptionRichnessOverride(systemTpl), userTpl
}
// Per-category prompt wins for the user message (company system keeps JSON schema / brand).
@@ -61,7 +61,25 @@ func resolveProductPromptTemplates(in ProductInput) (systemTpl, userTpl string)
}
// categories.prompt applies to name, description, and attrs (not description-only).
systemTpl = AppendCategoryEnhanceSystemOverlay(systemTpl, catPrompt)
return systemTpl, userTpl
return AppendDescriptionRichnessOverride(systemTpl), userTpl
}
// descriptionRichnessOverride is a platform-wide rule layered on top of every
// category prompt, so tenants keep their own prompts yet get fuller copy. Category
// prompts usually state modest word ranges and "shorter when sparse"; without this
// the model stops at the bottom of those ranges even when the source is rich.
const descriptionRichnessOverride = `Description depth (platform rule, applies on top of the Description formula): treat every word range in the formula as a minimum to reach whenever the input supports it, and aim for the upper end of it or more. Use ALL verified facts present in Name, Description and Attrs — every feature, technology, capability, connectivity, dimension, certification and warranty detail — and for each one explain what it means for the buyer in complete, developed sentences instead of a one-line summary. Fill every heading/paragraph pair the formula allows; when the supplied Description is rich, write full paragraphs, not a condensed recap, and never drop a supplied fact. Do not invent: any fact, number, percentage or specification must appear literally in the input. When the input is sparse, keep the text short rather than padding or guessing.`
// AppendDescriptionRichnessOverride appends descriptionRichnessOverride once.
func AppendDescriptionRichnessOverride(systemTpl string) string {
systemTpl = strings.TrimSpace(systemTpl)
if strings.Contains(systemTpl, "Description depth (platform rule") {
return systemTpl
}
if systemTpl == "" {
return descriptionRichnessOverride
}
return systemTpl + "\n" + descriptionRichnessOverride
}
// withDefaultCategoryFormula supplies the platform-default formula when the