p92 semantic patch

This commit is contained in:
team 1
2026-05-11 13:57:58 +02:00
parent c4890183f8
commit 50fb0bcc8e
4 changed files with 122 additions and 8 deletions

View File

@@ -5019,13 +5019,34 @@ final readonly class AgentRunner
*/
private function extractExactRequestedAccessoryCodes(string $prompt, string $shopSearchQuery): array
{
$text = $this->normalizeOneLine(trim($prompt . ' ' . $shopSearchQuery));
if ($text === '') {
$codeTerms = $this->agentRunnerConfig->getRequestedAccessoryCodeTerms();
if ($codeTerms === []) {
return [];
}
$codeTerms = $this->agentRunnerConfig->getRequestedAccessoryCodeTerms();
if ($codeTerms === []) {
// Prefer the already materialized Shopware query. It is a single, cleaned
// product-intent string and avoids accidentally joining a generic prompt
// reference such as "the indicator" with a device model number from the
// query context.
$codes = $this->extractExactRequestedAccessoryCodesFromText($shopSearchQuery, $codeTerms);
if ($codes !== []) {
return $codes;
}
return $this->extractExactRequestedAccessoryCodesFromText(
trim($prompt . ' ' . $shopSearchQuery),
$codeTerms
);
}
/**
* @param string[] $codeTerms
* @return string[]
*/
private function extractExactRequestedAccessoryCodesFromText(string $text, array $codeTerms): array
{
$text = $this->normalizeOneLine($text);
if ($text === '') {
return [];
}

View File

@@ -548,6 +548,22 @@ final class AgentRunnerConfig
return $terms;
}
/**
* @return string[]
*/
private function getGenreStringListOrVocabularyView(string $configPath, string $viewPathConfigPath): array
{
$viewPath = $this->genreString($viewPathConfigPath);
if ($viewPath !== '' && $this->vocabulary !== null) {
$terms = $this->vocabulary->view($viewPath, []);
if ($terms !== []) {
return $terms;
}
}
return $this->genreStringList($configPath);
}
/**
* @return array<string, string[]>
*/
@@ -1531,8 +1547,10 @@ final class AgentRunnerConfig
*/
public function getRequestedAccessoryCodeTerms(): array
{
return $this->genreStringList('search_repair.requested_accessory_code_terms.terms')
?: $this->genreStringList('product_roles.requested_accessory_code_terms.terms');
return $this->getGenreStringListOrVocabularyView(
'search_repair.requested_accessory_code_terms.terms',
'search_repair.requested_accessory_code_terms.vocabulary_views.terms'
) ?: $this->genreStringList('product_roles.requested_accessory_code_terms.terms');
}
public function isDirectShopResultGuardEnabled(): bool