This commit is contained in:
2026-08-23 12:40:59 +02:00
parent bd762d1ccf
commit 5340158228
11 changed files with 342 additions and 51 deletions
+21 -10
View File
@@ -15,24 +15,33 @@ const (
// spend thousands of tokens in reasoning_content before message.content.
// Formula HTML JSON often needs a large completion budget; 4096 hit
// finish_reason=length with empty/truncated content in live enhance.
MaxTokensEnhance = 16384
// GPT-5.6 max_completion_tokens includes hidden reasoning tokens — keep
// this high so multi-section HTML descriptions are not truncated.
MaxTokensEnhance = 24576
// MaxTokensEnhanceRetry is the one-shot length-cap bump ceiling used by
// OpenAIClient when finish_reason=length yields empty or unparseable JSON.
MaxTokensEnhanceRetry = 32768
MaxTokensEnhanceRetry = 40960
MaxTokensSEO = 180
MaxTokensCampaign = 650
MaxProductDescRunes = 400
MaxAttrKeys = 10
MaxAttrValueRunes = 60
MaxBrandInjectRunes = 500
MaxCampaignProducts = 8
MaxCampaignNameRunes = 80
// MaxProductDescRunes caps source description text fed into enhance prompts.
// Kept large enough for existing long/HTML descriptions so the model can
// rewrite factually instead of inventing from a truncated stub.
MaxProductDescRunes = 3500
MaxAttrKeys = 10
MaxAttrValueRunes = 60
MaxBrandInjectRunes = 500
MaxCampaignProducts = 8
MaxCampaignNameRunes = 80
)
// CompleteOptions tunes a single chat completion for structured tasks.
type CompleteOptions struct {
MaxTokens int
Temperature float64 // 0 → client default (≤0.3 for structured)
Temperature float64 // 0 → client default (≤0.3 for structured); omitted on GPT-5/o-series
// ReasoningEffort is Chat Completions reasoning_effort for GPT-5 / o-series.
// Empty → auto: "none" for tiny/probe budgets, "low" for content-heavy calls
// (long formula HTML) so visible tokens are not eaten by deep reasoning.
ReasoningEffort string
}
// CompleterWithOptions is optional; OpenAIClient implements it.
@@ -205,7 +214,9 @@ func CompactBrandPrompt(block string) string {
return truncateRunes(SanitizeText(block), MaxBrandInjectRunes)
}
// ProductEnhanceUser builds a short user prompt for title/description enhance.
// ProductEnhanceUser builds the compact user prompt for title/description enhance.
// Source description is capped at MaxProductDescRunes so long/HTML inputs stay available
// for factual rewrite (not invented from a short stub).
func ProductEnhanceUser(category, name, description string, attrs map[string]any) string {
var b strings.Builder
b.WriteString("Category: ")