fix
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/aiprompts"
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
|
||||
)
|
||||
|
||||
@@ -276,6 +277,26 @@ func AppendTitleFormulaSystemOverride(systemTpl string, titleTemplate any) strin
|
||||
return systemTpl + "\n" + titleFormulaSystemOverride
|
||||
}
|
||||
|
||||
// titlePromptRewriteOverride covers free-form Title section instructions
|
||||
// (categories.prompt --- Title ---) that are not structured title_template.
|
||||
const titlePromptRewriteOverride = `When the category Title section asks for a new product name or naming formula, "name" MUST be rewritten — never copy the supplier Name unchanged when type/brand/model/color (or other Title cues) are available. Obey the Title section over any "keep short retail title" guidance.`
|
||||
|
||||
// AppendTitlePromptRewriteOverride strengthens the system prompt when the
|
||||
// category Title role requires a rewrite. No-op when Title does not ask for one.
|
||||
func AppendTitlePromptRewriteOverride(systemTpl, categoryPrompt string) string {
|
||||
if !aiprompts.CategoryTitlePromptRequiresRewrite(categoryPrompt) {
|
||||
return strings.TrimSpace(systemTpl)
|
||||
}
|
||||
systemTpl = strings.TrimSpace(systemTpl)
|
||||
if systemTpl == "" {
|
||||
return titlePromptRewriteOverride
|
||||
}
|
||||
if strings.Contains(systemTpl, `"name" MUST be rewritten`) {
|
||||
return systemTpl
|
||||
}
|
||||
return systemTpl + "\n" + titlePromptRewriteOverride
|
||||
}
|
||||
|
||||
// categoryEnhanceSystemOverlay is appended when categories.prompt (enhance overlay)
|
||||
// is active so free-form category copy drives title, description, AND attributes —
|
||||
// not description alone — while Title/Description formulas keep structural precedence.
|
||||
|
||||
Reference in New Issue
Block a user