This commit is contained in:
team 1
2026-05-06 08:53:49 +02:00
parent 931af8b098
commit 130738e63b
8 changed files with 504 additions and 145 deletions

View File

@@ -82,7 +82,10 @@ final class AgentRunnerConfig
*/
public function getCommercialTableFollowUpTableTerms(): array
{
return $this->getRequiredStringList('follow_up_context.commercial_table_follow_up.table_terms');
return $this->getConfiguredStringListOrVocabularyView(
'follow_up_context.commercial_table_follow_up.table_terms',
'follow_up_context.commercial_table_follow_up.vocabulary_views.table_terms'
);
}
/**
@@ -828,7 +831,10 @@ final class AgentRunnerConfig
*/
public function getNoLlmMainDeviceRequestRoleKeywords(): array
{
return $this->getRequiredStringList('no_llm_fallback.product_roles.main_device_request_keywords');
return $this->getConfiguredStringListOrVocabularyView(
'no_llm_fallback.product_roles.main_device_request_keywords',
'no_llm_fallback.product_roles.vocabulary_views.main_device_request_keywords'
);
}
/**
@@ -836,7 +842,10 @@ final class AgentRunnerConfig
*/
public function getNoLlmAccessoryProductRoleKeywords(): array
{
return $this->getRequiredStringList('no_llm_fallback.product_roles.accessory_product_keywords');
return $this->getConfiguredStringListOrVocabularyView(
'no_llm_fallback.product_roles.accessory_product_keywords',
'no_llm_fallback.product_roles.vocabulary_views.accessory_product_keywords'
);
}
public function getNoLlmFallbackShopUnavailableWithKnowledgeMessage(): string
@@ -979,7 +988,10 @@ final class AgentRunnerConfig
*/
public function getShopQueryCurrentInputPreservationTerms(): array
{
return $this->getOptionalStringList('shop_prompt.current_input_preservation.terms');
return $this->getConfiguredStringListOrVocabularyView(
'shop_prompt.current_input_preservation.terms',
'shop_prompt.current_input_preservation.vocabulary_views.terms'
);
}
public function isShopQueryProductAttributeCleanupEnabled(): bool
@@ -1163,7 +1175,10 @@ final class AgentRunnerConfig
*/
public function getShopQueryContextAnchorEnrichmentTriggerTerms(): array
{
return $this->getRequiredStringList('shop_prompt.context_anchor_enrichment.trigger_terms');
return $this->getConfiguredStringListOrVocabularyView(
'shop_prompt.context_anchor_enrichment.trigger_terms',
'shop_prompt.context_anchor_enrichment.vocabulary_views.trigger_terms'
);
}
/**

View File

@@ -189,6 +189,49 @@ final class PromptBuilderConfig
return $terms;
}
/**
* @return array<string, string[]>
*/
private function getVocabularyStringListMap(string $mapPathConfigPath): array
{
if (!$this->hasPath($mapPathConfigPath)) {
return [];
}
if ($this->vocabulary === null) {
throw new \InvalidArgumentException(sprintf(
'RetrieX prompt vocabulary map config path "%s" is set but no vocabulary resolver is available.',
$mapPathConfigPath
));
}
$mapPath = $this->getRequiredString($mapPathConfigPath);
$map = $this->vocabulary->map($mapPath, []);
if ($map === []) {
throw new \InvalidArgumentException(sprintf(
'RetrieX prompt vocabulary map "%s" resolved to an empty map.',
$mapPath
));
}
return $map;
}
/**
* @param array<string, mixed> $item
* @param array<string, string[]> $vocabularyMap
* @return string[]
*/
private function getParameterStringList(array $item, string $id, string $localKey, array $vocabularyMap): array
{
if (array_key_exists($localKey, $item)) {
return $this->normalizeMixedStringList($item[$localKey]);
}
return $vocabularyMap[$id] ?? [];
}
/**
* @return string[]
*/
@@ -735,7 +778,10 @@ final class PromptBuilderConfig
*/
public function getMeasurementEvidenceAccessoryLookupGuardTerms(): array
{
return $this->getRequiredStringList('measurement_evidence_guard.accessory_lookup_guard_terms');
return $this->getConfiguredStringListOrVocabularyView(
'measurement_evidence_guard.accessory_lookup_guard_terms',
'measurement_evidence_guard.vocabulary_views.accessory_lookup_guard_terms'
);
}
/**
@@ -743,7 +789,10 @@ final class PromptBuilderConfig
*/
public function getMeasurementEvidenceAccessoryLookupPassthroughTerms(): array
{
return $this->getRequiredStringList('measurement_evidence_guard.accessory_lookup_passthrough_terms');
return $this->getConfiguredStringListOrVocabularyView(
'measurement_evidence_guard.accessory_lookup_passthrough_terms',
'measurement_evidence_guard.vocabulary_views.accessory_lookup_passthrough_terms'
);
}
public function getMeasurementEvidenceRuleTemplate(string $key): string
@@ -783,6 +832,9 @@ final class PromptBuilderConfig
$out = [];
$genericPositiveContextTerms = $this->getMeasurementEvidenceGenericPositiveContextTerms();
$genericNegativeContextTerms = $this->getMeasurementEvidenceGenericNegativeContextTerms();
$requestTermsByParameter = $this->getVocabularyStringListMap('measurement_evidence_guard.vocabulary_maps.request_terms');
$positiveTermsByParameter = $this->getVocabularyStringListMap('measurement_evidence_guard.vocabulary_maps.positive_terms');
$nonEquivalentTermsByParameter = $this->getVocabularyStringListMap('measurement_evidence_guard.vocabulary_maps.non_equivalent_terms');
foreach ($value as $item) {
if (!is_array($item)) {
@@ -799,15 +851,15 @@ final class PromptBuilderConfig
$out[] = [
'id' => $id,
'label' => $label,
'request_terms' => $this->normalizeMixedStringList($item['request_terms'] ?? []),
'positive_terms' => $this->normalizeMixedStringList($item['positive_terms'] ?? []),
'request_terms' => $this->getParameterStringList($item, $id, 'request_terms', $requestTermsByParameter),
'positive_terms' => $this->getParameterStringList($item, $id, 'positive_terms', $positiveTermsByParameter),
'positive_context_terms' => array_key_exists('positive_context_terms', $item)
? $this->normalizeMixedStringList($item['positive_context_terms'])
: $genericPositiveContextTerms,
'negative_context_terms' => array_key_exists('negative_context_terms', $item)
? $this->normalizeMixedStringList($item['negative_context_terms'])
: $genericNegativeContextTerms,
'non_equivalent_terms' => $this->normalizeMixedStringList($item['non_equivalent_terms'] ?? []),
'non_equivalent_terms' => $this->getParameterStringList($item, $id, 'non_equivalent_terms', $nonEquivalentTermsByParameter),
'safe_no_evidence_answer_de' => isset($item['safe_no_evidence_answer_de']) && is_scalar($item['safe_no_evidence_answer_de'])
? trim((string) $item['safe_no_evidence_answer_de'])
: '',