harden token config

This commit is contained in:
team 1
2026-04-26 15:20:06 +02:00
parent f34bc6b988
commit e3fd4541e4
6 changed files with 171 additions and 4 deletions

View File

@@ -52,7 +52,10 @@ final readonly class PromptBuilder
$systemBlock = $this->buildSystemBlock();
$shopBlock = $this->buildShopBlock($shopResults, $swagFullOutPut);
$outputPriorityBlock = $this->buildOutputPriorityBlock($hasShopResults);
$outputPriorityBlock = $this->buildOutputPriorityBlock(
hasShopResults: $hasShopResults,
isTechnicalProductQuestion: $isTechnicalProductQuestion
);
$responseFormatBlock = $this->buildResponseFormatBlock(
hasShopResults: $hasShopResults,
isTechnicalProductQuestion: $isTechnicalProductQuestion,
@@ -214,15 +217,25 @@ final readonly class PromptBuilder
/**
* Build a small priority block that tells the model what to surface first.
*/
private function buildOutputPriorityBlock(bool $hasShopResults): string
private function buildOutputPriorityBlock(bool $hasShopResults, bool $isTechnicalProductQuestion): string
{
if (!$hasShopResults) {
$rules = [];
if ($isTechnicalProductQuestion) {
$rules = array_merge($rules, $this->config->getOutputPriorityTechnicalRules());
}
if ($hasShopResults) {
$rules = array_merge($rules, $this->config->getOutputPriorityRules());
}
if ($rules === []) {
return '';
}
return $this->buildRuleBlock(
$this->config->getOutputPrioritySectionLabel(),
$this->config->getOutputPriorityRules()
$rules
);
}