This commit is contained in:
team 1
2026-05-05 12:12:51 +02:00
parent da374edcf4
commit 2c041a88c0
12 changed files with 429 additions and 282 deletions

View File

@@ -11,6 +11,7 @@ final class PromptBuilderConfig
*/
public function __construct(
private readonly array $config = [],
private readonly ?DomainVocabularyConfig $vocabulary = null,
) {
}
@@ -159,6 +160,35 @@ final class PromptBuilderConfig
return $out;
}
/**
* @return string[]
*/
private function getConfiguredStringListOrVocabularyView(string $configPath, string $viewPathConfigPath): array
{
if ($this->hasPath($configPath)) {
return $this->getRequiredStringList($configPath);
}
if ($this->vocabulary === null) {
throw new \InvalidArgumentException(sprintf(
'RetrieX prompt 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 prompt vocabulary view "%s" resolved to an empty list.',
$viewPath
));
}
return $terms;
}
/**
* @return string[]
*/
@@ -193,6 +223,21 @@ final class PromptBuilderConfig
private function hasPath(string $path): bool
{
$current = $this->config;
foreach (explode('.', $path) as $segment) {
if (!is_array($current) || !array_key_exists($segment, $current)) {
return false;
}
$current = $current[$segment];
}
return true;
}
private function getOptionalValue(string $path): mixed
{
$current = $this->config;
@@ -573,7 +618,10 @@ final class PromptBuilderConfig
*/
public function getTechnicalProductKeywords(): array
{
return $this->getRequiredStringList('technical_product_keywords');
return $this->getConfiguredStringListOrVocabularyView(
'technical_product_keywords',
'vocabulary_views.technical_product_keywords'
);
}
/**
@@ -581,7 +629,10 @@ final class PromptBuilderConfig
*/
public function getAccessoryRequestKeywords(): array
{
return $this->getRequiredStringList('accessory_request_keywords');
return $this->getConfiguredStringListOrVocabularyView(
'accessory_request_keywords',
'vocabulary_views.accessory_request_keywords'
);
}
public function getMeasurementEvidenceSectionLabel(): string