This commit is contained in:
2026-08-16 23:07:32 +02:00
parent 389608ea56
commit 6e77154228
14 changed files with 1189 additions and 21 deletions
+27 -7
View File
@@ -207,6 +207,10 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
out.FieldSources["eprel"] = "eprel_api"
appendStepLog(out.GPTResponse, StepEPREL, map[string]any{"status": "ok", "eprel_id": data.ID})
case StepCategorize:
// Vector (if enabled) then LLM taxonomy pick when category still empty.
runCategorizeStep(ctx, e, companyID, &out, in, categoryNames, policy)
case StepAIEnhance:
preservePriorEnhanceHash := func() {
if in.PriorEnhanceHash != "" {
@@ -501,11 +505,14 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
}
}
// Paths without fill_fields (enhance_only / normalize_only) still get vector
// categorize when AllowAI + embeddings are available.
tryVectorCategorize(ctx, e, companyID, &out, categoryNames, policy)
// Pipelines without StepCategorize (enhance_only / normalize_only) still try
// vector categorize when AllowAI + embeddings are available. Full/categorize
// already ran runCategorizeStep (vector then LLM) inside the loop.
if !stepsContain(steps, StepCategorize) {
tryVectorCategorize(ctx, e, companyID, &out, categoryNames, policy)
noteMissingCategory(&out, policy, e != nil && e.Vector != nil && e.Vector.Enabled())
}
preserveCategoryIfEmpty(&out, in.PriorCategory)
noteMissingCategory(&out, policy, e != nil && e.Vector != nil && e.Vector.Enabled())
syncCategoryName(&out, in.CategoryNamesByUID)
out.Name = preferredProductTitle(in.GTIN, out.Name, out.ProcessedName, in.Name, in.PriorProcessedName)
out.ProcessedName = preferredProductTitle(in.GTIN, out.ProcessedName, out.Name, in.PriorProcessedName, in.Name)
@@ -640,12 +647,14 @@ func tryVectorCategorize(ctx context.Context, e *Engine, companyID string, out *
}
// noteMissingCategory records why Category stayed empty (mapped absent; vector skipped or failed).
// Used for pipelines that skip StepCategorize (vector-only post-pass).
func noteMissingCategory(out *StepResult, policy StepPolicy, vectorEnabled bool) {
if out == nil || strings.TrimSpace(out.Category) != "" {
return
}
for _, n := range out.Notes {
if strings.HasPrefix(n, "category: unset") || strings.HasPrefix(n, "category: vector") {
if strings.HasPrefix(n, "category: unset") || strings.HasPrefix(n, "category: vector") ||
strings.HasPrefix(n, "category: llm") || strings.HasPrefix(n, "ai_categorize:") {
return
}
}
@@ -670,14 +679,25 @@ func resolveSteps(processingType string) []string {
return []string{StepNormalize, StepParseSpecs, StepEPREL}
case "normalize_only":
return []string{StepNormalize}
case "categorize", "categorize_only", "categorize_enhance":
// Legacy aliases → full deterministic + optional AI
case "categorize", "categorize_only":
// Taxonomy assign only (vector then LLM) — no title/description rewrite.
return []string{StepNormalize, StepParseSpecs, StepFillFields, StepEPREL, StepCategorize}
case "categorize_enhance":
return append([]string{}, CanonicalSteps...)
default: // full
return append([]string{}, CanonicalSteps...)
}
}
func stepsContain(steps []string, want string) bool {
for _, s := range steps {
if s == want {
return true
}
}
return false
}
// InitialStepProgress builds pending step_progress rows for a job.
func InitialStepProgress(processingType string) []StepProgress {
steps := resolveSteps(processingType)