Fixes
This commit is contained in:
1 parent
04794aea54
commit
cfd31f398c
61 files changed
+2062
-254
No files matched your search
@@ -314,10 +314,22 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
|
||||
priorDesc = in.PriorProcessedDescription
|
||||
}
|
||||
}
|
||||
metaOnly := strings.EqualFold(strings.TrimSpace(processingType), "seo_meta")
|
||||
promptName, promptDesc := out.Name, out.Description
|
||||
if metaOnly {
|
||||
if priorName != "" {
|
||||
promptName = priorName
|
||||
}
|
||||
if priorDesc != "" {
|
||||
promptDesc = priorDesc
|
||||
}
|
||||
// Bypass unrelated description/title hash caching for a metadata refresh.
|
||||
priorHash = ""
|
||||
}
|
||||
name, desc, tokens, raw, err := e.enhance(ctx, ProductInput{
|
||||
GTIN: in.GTIN,
|
||||
Name: out.Name,
|
||||
Description: out.Description,
|
||||
Name: promptName,
|
||||
Description: promptDesc,
|
||||
Mapped: normalized,
|
||||
BrandPrompt: in.BrandPrompt,
|
||||
Language: lang,
|
||||
@@ -405,6 +417,14 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
|
||||
allUnchanged = false
|
||||
}
|
||||
}
|
||||
if metaOnly {
|
||||
// Do not persist unrelated AI rewrites on SEO-only jobs.
|
||||
name, desc = promptName, promptDesc
|
||||
persistHash = company.FieldsForLanguage(in.PriorLocalized, lang).EnhanceInputHash
|
||||
if lang == primary && persistHash == "" {
|
||||
persistHash = in.PriorEnhanceHash
|
||||
}
|
||||
}
|
||||
localized[lang] = company.LocalizedFields{
|
||||
ProcessedName: name,
|
||||
ProcessedDescription: desc,
|
||||
@@ -444,7 +464,7 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
|
||||
}
|
||||
// Merge LLM attrs onto pipeline attrs (validated against category keys).
|
||||
// Attrs are independent of title/description soft-fail (synthesized/refused).
|
||||
if err == nil && status != "failed" && status != "parse_failed" {
|
||||
if !metaOnly && err == nil && status != "failed" && status != "parse_failed" {
|
||||
if merged := mergeEnhanceAttrsInto(attrs, enhanceAttrsFromRaw(raw), enhanceAllowedAttrKeys(in, out.Category)); len(merged) > 0 {
|
||||
attrs = merged
|
||||
enhanceAttrs = AttrsForEnhance(attrs, enhanceAllowedAttrKeys(in, out.Category))
|
||||
@@ -576,7 +596,7 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
|
||||
// repair short prose / title echo that ignored A1 description_template.
|
||||
finalDescTpl := effectiveDescriptionTemplateFor(in, out)
|
||||
finalRepaired := false
|
||||
if descriptionNeedsEnhanceRepair(out.ProcessedDescription, finalDescTpl, out.ProcessedName, out.Name) {
|
||||
if !strings.EqualFold(strings.TrimSpace(processingType), "seo_meta") && descriptionNeedsEnhanceRepair(out.ProcessedDescription, finalDescTpl, out.ProcessedName, out.Name) {
|
||||
if synth := synthesizeProductDescription(out.ProcessedName, displayCat, in.Language, out.Attributes, finalDescTpl); synth != "" {
|
||||
out.ProcessedDescription = synth
|
||||
finalRepaired = true
|
||||
@@ -605,6 +625,36 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
|
||||
out.LocalizedContent[lang] = lf
|
||||
}
|
||||
}
|
||||
if strings.EqualFold(strings.TrimSpace(processingType), "seo_meta") {
|
||||
// Preserve existing product copy even if enhancement attempted title/description
|
||||
// repair internally while building SEO metadata.
|
||||
if in.PriorProcessedName != "" {
|
||||
out.ProcessedName = in.PriorProcessedName
|
||||
} else {
|
||||
out.ProcessedName = out.Name
|
||||
}
|
||||
if in.PriorProcessedDescription != "" {
|
||||
out.ProcessedDescription = in.PriorProcessedDescription
|
||||
} else {
|
||||
out.ProcessedDescription = out.Description
|
||||
}
|
||||
for lang, fields := range out.LocalizedContent {
|
||||
old := company.FieldsForLanguage(in.PriorLocalized, lang)
|
||||
if old.ProcessedName != "" {
|
||||
fields.ProcessedName = old.ProcessedName
|
||||
} else {
|
||||
fields.ProcessedName = out.Name
|
||||
}
|
||||
if old.ProcessedDescription != "" {
|
||||
fields.ProcessedDescription = old.ProcessedDescription
|
||||
} else {
|
||||
fields.ProcessedDescription = out.Description
|
||||
}
|
||||
out.LocalizedContent[lang] = fields
|
||||
}
|
||||
delete(out.FieldSources, "name")
|
||||
delete(out.FieldSources, "description")
|
||||
}
|
||||
if out.Attributes == nil {
|
||||
out.Attributes = map[string]any{}
|
||||
}
|
||||
@@ -708,7 +758,7 @@ func noteMissingCategory(out *StepResult, policy StepPolicy, vectorEnabled bool)
|
||||
|
||||
func resolveSteps(processingType string) []string {
|
||||
switch strings.ToLower(strings.TrimSpace(processingType)) {
|
||||
case "enhance", "enhance_only", "enhance-only", "title", "description":
|
||||
case "enhance", "enhance_only", "enhance-only", "title", "description", "seo_meta":
|
||||
// parse_specs/fill_fields/categorize feed ai_enhance — they never rewrite
|
||||
// title/description themselves. Without them enhance ran with empty Attrs
|
||||
// and (for feeds without a mapped category) no category, so the category
|
||||
|
||||
Reference in new issue
Block a user