This commit is contained in:
2026-08-16 21:35:48 +02:00
parent 106f602232
commit 389608ea56
28 changed files with 2491 additions and 115 deletions
@@ -5,6 +5,8 @@ import (
"fmt"
"strconv"
"strings"
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
)
// AppendFormulaConstraints appends language-agnostic title/description formula
@@ -118,6 +120,24 @@ func AppendDescriptionFormulaSystemOverride(systemTpl string, descriptionTemplat
return systemTpl + "\n" + descriptionFormulaSystemOverride
}
// descriptionSatisfiesFormula reports whether desc includes the HTML tags required
// by categories.description_template sections. No formula → always true.
func descriptionSatisfiesFormula(desc string, template any) bool {
sections, ok := parseDescriptionFormulaSections(template)
if !ok || len(sections) == 0 {
return true
}
desc = strings.TrimSpace(desc)
if desc == "" || desc == "<nil>" {
return false
}
types := make([]string, 0, len(sections))
for _, s := range sections {
types = append(types, s.Type)
}
return !company.DescriptionMissingFormulaHTMLTags(desc, types)
}
type titleFormulaElement struct {
Type string `json:"type"`
Value string `json:"value"`