fix
This commit is contained in:
@@ -20,6 +20,10 @@ type FixCompanyCatalogOpts struct {
|
||||
ReprocessSampleLimit int
|
||||
// AIPrompts optionally re-applies BuiltInDefaults product_enhance per content language.
|
||||
AIPrompts *aiprompts.Service
|
||||
// WPCategoriesSQL is an uploaded wp_product_categories.sql dump. When set,
|
||||
// RepairCompanyCategoryEnhancePrompts force-applies overlays from these bytes
|
||||
// (Admin Sync A1 primary path). Empty keeps filesystem auto-detect fallback.
|
||||
WPCategoriesSQL []byte
|
||||
}
|
||||
|
||||
// FixCompanyCatalogResult is the idempotent admin Fix A1 report.
|
||||
@@ -36,6 +40,10 @@ type FixCompanyCatalogResult struct {
|
||||
CategoryPromptsEmpty int `json:"category_prompts_empty_skipped"`
|
||||
// Prompts aliases category_prompts_updated for flash.admin.fixA1Success {prompts}.
|
||||
Prompts int `json:"prompts"`
|
||||
// WPCategoriesPath is set when prompts came from wp_product_categories.sql
|
||||
// (upload:… or a resolved filesystem path).
|
||||
WPCategoriesPath string `json:"wp_categories_path,omitempty"`
|
||||
WPCategoriesEntries int `json:"wp_categories_entries,omitempty"`
|
||||
|
||||
ProductEnhanceLanguages int `json:"product_enhance_languages"`
|
||||
|
||||
@@ -88,13 +96,17 @@ func FixCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, companyID uuid.U
|
||||
out.CategoryAttributeOrphansRemoved = orphans
|
||||
out.CategoryAttributeLinks = links
|
||||
|
||||
updated, alreadyOK, emptySkipped, err := catalog.RepairCompanyCategoryEnhancePrompts(ctx, pool, companyID)
|
||||
updatedRes, err := catalog.RepairCompanyCategoryEnhancePromptsWithOptions(ctx, pool, companyID, catalog.RepairA1DemoOptions{
|
||||
WPCategoriesSQL: opts.WPCategoriesSQL,
|
||||
})
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
out.CategoryPromptsUpdated = updated
|
||||
out.CategoryPromptsAlreadyOK = alreadyOK
|
||||
out.CategoryPromptsEmpty = emptySkipped
|
||||
out.CategoryPromptsUpdated = updatedRes.Updated
|
||||
out.CategoryPromptsAlreadyOK = updatedRes.AlreadyOK
|
||||
out.CategoryPromptsEmpty = updatedRes.EmptySkipped
|
||||
out.WPCategoriesPath = updatedRes.WPCategoriesPath
|
||||
out.WPCategoriesEntries = updatedRes.SeedEntries
|
||||
|
||||
if opts.AIPrompts != nil {
|
||||
n, err := opts.AIPrompts.ApplyBuiltInProductEnhance(ctx, companyID)
|
||||
|
||||
@@ -174,7 +174,7 @@ func FormatTitleFormulaConstraint(template any) string {
|
||||
continue
|
||||
}
|
||||
}
|
||||
b.WriteString("Prefer Attrs values for [attr] slots; keep literal text as written; write name in {{language}}.")
|
||||
b.WriteString("Prefer Attrs values for [attr] slots; keep literal text as written; write name in {{language}}; never emit brand-only when product_type or product_model slots exist.")
|
||||
return strings.TrimSpace(b.String())
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func AppendDescriptionFormulaSystemOverride(systemTpl string, descriptionTemplat
|
||||
// titleFormulaSystemOverride is appended to the enhance system template when a
|
||||
// category title_template is present so company/built-in "short retail title"
|
||||
// rules cannot ignore the Title formula (mirrors description formula override).
|
||||
const titleFormulaSystemOverride = `When the user message includes a "Title formula", obey that structure for "name" over any shorter "short retail title" guidance: build name from Attrs in the given element order, keep literal text as written, write name in {{language}}. Never ignore the Title formula.`
|
||||
const titleFormulaSystemOverride = `When the user message includes a "Title formula", obey that structure for "name" over any shorter "short retail title" guidance: build name from Attrs in the given element order, keep literal text as written, write name in {{language}}. Never ignore the Title formula. Never emit brand-only when the formula includes product_type or product_model.`
|
||||
|
||||
// AppendTitleFormulaSystemOverride strengthens the system prompt when a title
|
||||
// formula is active. No-op when template is empty/unparseable.
|
||||
|
||||
Reference in New Issue
Block a user