p43E
This commit is contained in:
@@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,10 @@ final class SearchRepairConfig
|
||||
/** @return string[] */
|
||||
public function getDirectProductAttributeLookupStopTerms(): array
|
||||
{
|
||||
return $this->requiredStringList('direct_product_attribute_lookup.stop_terms');
|
||||
return $this->configOrVocabularyStringList(
|
||||
'direct_product_attribute_lookup.stop_terms',
|
||||
'search_repair.direct_product_attribute_stop_terms'
|
||||
);
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
|
||||
Reference in New Issue
Block a user