This commit is contained in:
team 1
2026-05-05 16:37:27 +02:00
parent 7e868be24e
commit 542b527261
7 changed files with 180 additions and 98 deletions

View File

@@ -11,6 +11,7 @@ final class AgentRunnerConfig
*/
public function __construct(
private readonly array $config = [],
private readonly ?DomainVocabularyConfig $vocabulary = null,
) {
}
@@ -420,6 +421,35 @@ final class AgentRunnerConfig
}
/**
* @return string[]
*/
private function getConfiguredStringListOrVocabularyView(string $configPath, string $viewPathConfigPath): array
{
if ($this->optionalValue($configPath) !== null) {
return $this->getRequiredStringList($configPath);
}
if ($this->vocabulary === null) {
throw new \InvalidArgumentException(sprintf(
'RetrieX agent config path "%s" is missing and no vocabulary resolver is available.',
$configPath
));
}
$viewPath = $this->getRequiredString($viewPathConfigPath);
$terms = $this->vocabulary->view($viewPath, []);
if ($terms === []) {
throw new \InvalidArgumentException(sprintf(
'RetrieX agent vocabulary view "%s" resolved to an empty list.',
$viewPath
));
}
return $terms;
}
/**
* @return array<int, array{label:string, prompt:string}>
*/
@@ -932,7 +962,10 @@ final class AgentRunnerConfig
*/
public function getShopQueryProductAttributeCleanupProductTypeTerms(): array
{
return $this->getRequiredStringList('shop_prompt.product_attribute_query_cleanup.product_type_terms');
return $this->getConfiguredStringListOrVocabularyView(
'shop_prompt.product_attribute_query_cleanup.product_type_terms',
'shop_prompt.product_attribute_query_cleanup.vocabulary_views.product_type_terms'
);
}
/**
@@ -940,7 +973,10 @@ final class AgentRunnerConfig
*/
public function getShopQueryProductAttributeCleanupStopTerms(): array
{
return $this->getRequiredStringList('shop_prompt.product_attribute_query_cleanup.stop_terms');
return $this->getConfiguredStringListOrVocabularyView(
'shop_prompt.product_attribute_query_cleanup.stop_terms',
'shop_prompt.product_attribute_query_cleanup.vocabulary_views.stop_terms'
);
}
/**