optimize technical truth
This commit is contained in:
@@ -53,14 +53,8 @@ final readonly class AgentRunner
|
||||
$primaryShopResults = [];
|
||||
$knowledgeChunks = [];
|
||||
$sources = [];
|
||||
$urlContent = '';
|
||||
$optimizedShopQuery = '';
|
||||
$shopSearchQuery = '';
|
||||
$shopSearchDisplayQuery = '';
|
||||
$shopSearchUsedOptimizedQuery = false;
|
||||
$commerceIntent = CommerceIntentLite::NONE;
|
||||
$knowledgeRetrievalPrompt = $prompt;
|
||||
$usedFollowUpRetrievalContext = false;
|
||||
$commerceHistoryContext = '';
|
||||
$attemptedShopRepair = false;
|
||||
$usedShopRepair = false;
|
||||
@@ -311,7 +305,7 @@ final readonly class AgentRunner
|
||||
$usedShopRepair = $repairPayload['usedRepair'];
|
||||
$shopRepairQueries = $repairPayload['repairQueries'];
|
||||
|
||||
if ($shopSearchQuery !== '' && !$primaryShopSearchHadSystemFailure) {
|
||||
if (!$primaryShopSearchHadSystemFailure) {
|
||||
yield $this->systemMsg(
|
||||
$this->buildShopSearchMetaMessage(
|
||||
query: $shopSearchDisplayQuery !== '' ? $shopSearchDisplayQuery : $shopSearchQuery,
|
||||
@@ -757,7 +751,7 @@ final readonly class AgentRunner
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = $this->sanitizeHistoryQuestion((string) ($matches[0] ?? ''));
|
||||
$value = $this->sanitizeHistoryQuestion(($matches[0] ?? ''));
|
||||
$value = preg_replace('/\s+/u', ' ', $value) ?? $value;
|
||||
|
||||
return trim(str_replace('®', '', $value));
|
||||
@@ -769,7 +763,7 @@ final readonly class AgentRunner
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = preg_replace('/\s+/u', ' ', (string) ($matches[0] ?? '')) ?? '';
|
||||
$value = preg_replace('/\s+/u', ' ', ($matches[0] ?? '')) ?? '';
|
||||
|
||||
return trim($value);
|
||||
}
|
||||
@@ -1820,6 +1814,10 @@ final readonly class AgentRunner
|
||||
private function formatProductionUiSourceLabels(array $sourceLabels): array
|
||||
{
|
||||
$labels = [];
|
||||
$seen = [];
|
||||
$shopSystemKey = $this->canonicalProductionUiSourceLabelKey(
|
||||
$this->plainTextFromHtml($this->agentRunnerConfig->getShopSystemSourceLabel())
|
||||
);
|
||||
|
||||
foreach ($sourceLabels as $label) {
|
||||
// Source labels are stored as badge HTML for the legacy "Genutzte Quellen" line.
|
||||
@@ -1831,18 +1829,35 @@ final readonly class AgentRunner
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($label === $this->plainTextFromHtml($this->agentRunnerConfig->getShopSystemSourceLabel())) {
|
||||
$key = $this->canonicalProductionUiSourceLabelKey($label);
|
||||
|
||||
if ($key === $shopSystemKey || $key === 'liveshopdaten') {
|
||||
$label = 'Live-Shopdaten';
|
||||
$key = 'liveshopdaten';
|
||||
}
|
||||
|
||||
if (!in_array($label, $labels, true)) {
|
||||
$labels[] = $label;
|
||||
if (isset($seen[$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$key] = true;
|
||||
$labels[] = $label;
|
||||
}
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
private function canonicalProductionUiSourceLabelKey(string $label): string
|
||||
{
|
||||
$label = html_entity_decode(strip_tags($label), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$label = str_replace(["\xc2\xa0", '‐', '‑', '‒', '–', '—'], [' ', '-', '-', '-', '-', '-'], $label);
|
||||
$label = preg_replace('/\s+/u', ' ', $label) ?? $label;
|
||||
$label = mb_strtolower(trim($label), 'UTF-8');
|
||||
$label = preg_replace('/[^\p{L}\p{N}]+/u', '', $label) ?? $label;
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShopProductResult[] $shopResults
|
||||
*/
|
||||
@@ -1863,7 +1878,7 @@ final readonly class AgentRunner
|
||||
}
|
||||
|
||||
$html = '<div class="retriex-meta-card retriex-product-results" data-retriex-meta-id="shop-results" data-retriex-meta-state="completed">'
|
||||
. '<div class="retriex-meta-card__eyebrow">Live-Shopdaten</div>'
|
||||
. '<div class="retriex-meta-card__eyebrow">Shop-Ergebnisse</div>'
|
||||
. '<div class="retriex-meta-card__title">Shop-Ergebnisse</div>'
|
||||
. '<div class="retriex-product-results__summary">' . htmlspecialchars($summary, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</div>';
|
||||
|
||||
@@ -2053,7 +2068,7 @@ final readonly class AgentRunner
|
||||
. '" data-retriex-shop-result-count="'
|
||||
. htmlspecialchars($resultCountAttribute, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')
|
||||
. '">'
|
||||
. '<div class="retriex-meta-card__eyebrow">Live-Shopdaten</div>'
|
||||
. '<div class="retriex-meta-card__eyebrow">Shop-Suche</div>'
|
||||
. '<div class="retriex-meta-card__title">' . htmlspecialchars($title, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</div>'
|
||||
. '<div class="retriex-meta-card__body">'
|
||||
. '<span class="retriex-meta-pill retriex-meta-pill--result">' . htmlspecialchars($resultLabel, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</span>'
|
||||
|
||||
Reference in New Issue
Block a user