This commit is contained in:
2026-08-16 16:57:36 +02:00
parent 96f8c1115c
commit 532d439c41
106 changed files with 10147 additions and 494 deletions
+14 -11
View File
@@ -11,15 +11,18 @@ import (
// Local / weak-model defaults (8k-class context). See docs/local-llm-tuning.md.
const (
DefaultStructuredTemp = 0.2
MaxTokensEnhance = 350
MaxTokensSEO = 180
MaxTokensCampaign = 650
MaxProductDescRunes = 400
MaxAttrKeys = 10
MaxAttrValueRunes = 60
MaxBrandInjectRunes = 500
MaxCampaignProducts = 8
MaxCampaignNameRunes = 80
// Reasoning-capable OpenAI-compatible models (e.g. code-fast / Qwen3) spend
// hundredsthousands of tokens in reasoning_content before writing message.content.
// 350 capped mid-thought → empty content → "empty model response".
MaxTokensEnhance = 4096
MaxTokensSEO = 180
MaxTokensCampaign = 650
MaxProductDescRunes = 400
MaxAttrKeys = 10
MaxAttrValueRunes = 60
MaxBrandInjectRunes = 500
MaxCampaignProducts = 8
MaxCampaignNameRunes = 80
)
// CompleteOptions tunes a single chat completion for structured tasks.
@@ -152,14 +155,14 @@ func CompactAttrs(attrs map[string]any, maxKeys int) map[string]any {
keys := make([]string, 0, len(attrs))
for k := range attrs {
k = strings.TrimSpace(k)
if k == "" {
if k == "" || isInvalidAttributeKey(k) {
continue
}
keys = append(keys, k)
}
sort.Strings(keys)
// Prefer common retail keys first.
priority := []string{"brand", "Brand", "color", "Color", "material", "Material", "size", "Size", "model", "Model", "gtin", "GTIN", "ean", "EAN"}
priority := []string{"brand", "Brand", "product_model", "color", "Color", "material", "Material", "size", "Size", "model", "Model", "gtin", "GTIN", "ean", "EAN"}
ordered := make([]string, 0, len(keys))
seen := map[string]bool{}
for _, p := range priority {