p36c
This commit is contained in:
@@ -985,7 +985,12 @@ final readonly class AgentRunner
|
||||
private function normalizeFuzzyRoutingToken(string $token): string
|
||||
{
|
||||
$token = mb_strtolower(trim($token), 'UTF-8');
|
||||
$token = $this->languageCleanupConfig->transliterateToAscii($token);
|
||||
$token = strtr($token, [
|
||||
'ä' => 'ae',
|
||||
'ö' => 'oe',
|
||||
'ü' => 'ue',
|
||||
'ß' => 'ss',
|
||||
]);
|
||||
$token = preg_replace('/[^a-z0-9]+/u', '', $token) ?? $token;
|
||||
|
||||
return trim($token);
|
||||
@@ -1023,13 +1028,13 @@ final readonly class AgentRunner
|
||||
{
|
||||
$normalized = $this->normalizeRoutingComparisonText($candidate);
|
||||
|
||||
foreach ($this->agentRunnerConfig->getInputNormalizationPlaceholderOutputs() as $placeholderOutput) {
|
||||
if ($normalized === $this->normalizeRoutingComparisonText($placeholderOutput)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return in_array($normalized, [
|
||||
'normalized user input',
|
||||
'corrected user input',
|
||||
'user input',
|
||||
'normalisierte nutzereingabe',
|
||||
'korrigierte nutzereingabe',
|
||||
], true);
|
||||
}
|
||||
|
||||
private function normalizeRoutingComparisonText(string $value): string
|
||||
@@ -1636,10 +1641,56 @@ final readonly class AgentRunner
|
||||
$guardedQuery = $this->guardStandaloneOptimizedShopQuery($prompt, $shopSearchQuery);
|
||||
|
||||
if ($guardedQuery !== $shopSearchQuery) {
|
||||
return $guardedQuery;
|
||||
return $this->preserveCurrentInputShopQueryTerms($prompt, $guardedQuery);
|
||||
}
|
||||
|
||||
return $shopSearchQuery;
|
||||
return $this->preserveCurrentInputShopQueryTerms($prompt, $shopSearchQuery);
|
||||
}
|
||||
|
||||
private function preserveCurrentInputShopQueryTerms(string $prompt, string $shopSearchQuery): string
|
||||
{
|
||||
$shopSearchQuery = trim($shopSearchQuery);
|
||||
|
||||
if ($shopSearchQuery === '' || !$this->agentRunnerConfig->isShopQueryCurrentInputPreservationEnabled()) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
$promptTokens = array_fill_keys($this->tokenizeShopQueryCandidate($prompt), true);
|
||||
$queryTokens = array_fill_keys($this->tokenizeShopQueryCandidate($shopSearchQuery), true);
|
||||
|
||||
if ($promptTokens === [] || $queryTokens === []) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
$appendTokens = [];
|
||||
|
||||
$preservationTerms = $this->mergeUniqueStrings(
|
||||
$this->languageCleanupConfig->getProtectedTerms(),
|
||||
$this->agentRunnerConfig->getShopQueryCurrentInputPreservationTerms()
|
||||
);
|
||||
|
||||
foreach ($preservationTerms as $term) {
|
||||
$termTokens = $this->tokenizeShopQueryCandidate($term);
|
||||
|
||||
if ($termTokens === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($termTokens as $termToken) {
|
||||
if (!isset($promptTokens[$termToken]) || isset($queryTokens[$termToken])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$appendTokens[$termToken] = $termToken;
|
||||
$queryTokens[$termToken] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($appendTokens === []) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
return trim($shopSearchQuery . ' ' . implode(' ', array_values($appendTokens)));
|
||||
}
|
||||
|
||||
private function standaloneOptimizedShopQueryIntroducesUnsupportedContext(
|
||||
@@ -2852,7 +2903,12 @@ final readonly class AgentRunner
|
||||
$value = html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$value = mb_strtolower($value, 'UTF-8');
|
||||
$value = str_replace(['‐', '‑', '‒', '–', '—'], '-', $value);
|
||||
$value = $this->languageCleanupConfig->transliterateToAscii($value);
|
||||
$value = strtr($value, [
|
||||
'ä' => 'ae',
|
||||
'ö' => 'oe',
|
||||
'ü' => 'ue',
|
||||
'ß' => 'ss',
|
||||
]);
|
||||
$value = preg_replace('/\s+/u', ' ', $value) ?? $value;
|
||||
|
||||
return trim($value);
|
||||
@@ -3231,15 +3287,14 @@ final readonly class AgentRunner
|
||||
$actions = [];
|
||||
|
||||
if ($isCommerceIntent || $hasShopResults) {
|
||||
foreach ($this->agentRunnerConfig->getCommerceFollowUpActions() as $label => $actionPrompt) {
|
||||
$actions[] = [$label, $actionPrompt];
|
||||
}
|
||||
$actions[] = ['Im Shop suchen', 'Suche die aktuelle Produktauswahl im Shop.'];
|
||||
$actions[] = ['Nur Zubehör anzeigen', 'Zeige aus der aktuellen Produktauswahl nur Zubehör.'];
|
||||
$actions[] = ['Nur Geräte anzeigen', 'Zeige aus der aktuellen Produktauswahl nur Geräte.'];
|
||||
$actions[] = ['Preis anzeigen', 'Zeige mir die Preise der aktuell relevanten Produkte.'];
|
||||
}
|
||||
|
||||
if ($hasKnowledge || $hasShopResults) {
|
||||
foreach ($this->agentRunnerConfig->getKnowledgeFollowUpActions() as $label => $actionPrompt) {
|
||||
$actions[] = [$label, $actionPrompt];
|
||||
}
|
||||
$actions[] = ['Technische Details anzeigen', 'Zeige technische Details zur aktuellen Antwort.'];
|
||||
}
|
||||
|
||||
if ($actions === []) {
|
||||
|
||||
Reference in New Issue
Block a user