This commit is contained in:
greeneclipse committed 2026-10-14 19:23:16 +02:00
1 parent ff6c2df618
commit 43cfaa0411
18 files changed
+683 -299

No files matched your search

+11 -8
View File
@@ -243,14 +243,14 @@ func FormatMetaFormulaConstraint(template any) string {
b.WriteString("SEO meta formula (REQUIRED — distinct from description HTML; plain text only):\n")
b.WriteString("Emit meta_title and meta_description as separate JSON fields in {{language}}.\n")
if metaTitle != "" {
fmt.Fprintf(&b, "- meta_title (50-60 chars): %s\n", metaTitle)
fmt.Fprintf(&b, "- meta_title (concise and distinctive; typically 50–60 characters when natural): %s\n", metaTitle)
} else {
b.WriteString("- meta_title: 50-60 chars, product name + main benefit or use case\n")
b.WriteString("- meta_title: product name + confirmed characteristic, concise and unique\n")
}
if metaDesc != "" {
fmt.Fprintf(&b, "- meta_description (120-155 chars): %s\n", metaDesc)
fmt.Fprintf(&b, "- meta_description (factual, 155 characters maximum; shorter with sparse data): %s\n", metaDesc)
} else {
b.WriteString("- meta_description: 120-155 chars, factual SEO snippet; never HTML\n")
b.WriteString("- meta_description: factual SEO snippet up to 155 characters; never HTML\n")
}
return strings.TrimSpace(b.String())
}
@@ -265,7 +265,7 @@ func FormatDescriptionFormulaConstraint(template any) string {
var b strings.Builder
b.WriteString("Description formula (REQUIRED — overrides any shorter \"1-2 sentences\" rule):\n")
b.WriteString("Emit description as ONE HTML string covering each section in order in {{language}}.\n")
b.WriteString("Use tags matching section type: h1/h2/h3/h4 → <hN>…</hN>, p → <p>…</p>, ul → <ul><li>…</li></ul>.\n")
b.WriteString("Use semantic product-detail HTML only: p → <p>…</p>, h2 → <h2>…</h2>, ul → <ul><li>…</li></ul>. No H1, no product-title duplicate. Skip optional feature/specification blocks when evidence does not support them; never emit empty elements.\n")
for _, s := range sections {
typ := strings.TrimSpace(s.Type)
instr := strings.TrimSpace(s.Instructions)
@@ -279,7 +279,7 @@ func FormatDescriptionFormulaConstraint(template any) string {
fmt.Fprintf(&b, "- %s\n", typ)
continue
}
fmt.Fprintf(&b, "- %s: %s\n", typ, instr)
fmt.Fprintf(&b, "- %s%s: %s\n", typ, map[bool]string{true: " (optional when no sourced facts)", false: ""}[s.Optional], instr)
}
return strings.TrimSpace(b.String())
}
@@ -287,7 +287,7 @@ func FormatDescriptionFormulaConstraint(template any) string {
// descriptionFormulaSystemOverride is appended to the enhance system template when a
// category description_template is present so company/built-in "1-2 sentences" rules
// cannot override the per-category formula (A1 category definition pages).
const descriptionFormulaSystemOverride = `When the user message includes a "Description formula", obey those sections over any shorter "1-2 sentences" / "1-3 paragraphs" guidance: emit one HTML string using tags matching each section type (h1/h2/h3/h4, p, ul), in order, in {{language}}. Never ignore the Description formula.`
const descriptionFormulaSystemOverride = `When the user message includes a "Description formula", obey those sections over any shorter "1-2 sentences" / "1-3 paragraphs" guidance: emit one HTML string using all REQUIRED sections, omitting OPTIONAL ones when no verified facts exist; use tags matching each section type (h1/h2/h3/h4, p, ul), in order, in {{language}}. Never ignore the Description formula.`
// AppendDescriptionFormulaSystemOverride strengthens the system prompt when a
// description formula is active. No-op when template is empty/unparseable.
@@ -406,7 +406,9 @@ func descriptionSatisfiesFormula(desc string, template any) bool {
}
types := make([]string, 0, len(sections))
for _, s := range sections {
types = append(types, s.Type)
if !s.Optional {
types = append(types, s.Type)
}
}
return !company.DescriptionMissingFormulaHTMLTags(desc, types)
}
@@ -419,6 +421,7 @@ type titleFormulaElement struct {
type descriptionFormulaSection struct {
Type string `json:"type"`
Instructions string `json:"instructions"`
Optional bool `json:"optional,omitempty"`
}
func parseTitleFormula(template any) (elements []titleFormulaElement, separator string, ok bool) {