This commit is contained in:
team 1
2026-05-04 17:49:01 +02:00
parent 387506b239
commit 794ab1a30b
9 changed files with 256 additions and 107 deletions

View File

@@ -260,26 +260,6 @@ final class AgentRunnerConfig
return $this->getRequiredStringList('input_normalization.fuzzy_routing.terms');
}
/**
* @return string[]
*/
public function getInputNormalizationPlaceholderOutputs(): array
{
return $this->getRequiredStringList('input_normalization.placeholder_outputs');
}
/** @return array<string, string> */
public function getCommerceFollowUpActions(): array
{
return $this->getRequiredStringMap('followup_actions.commerce');
}
/** @return array<string, string> */
public function getKnowledgeFollowUpActions(): array
{
return $this->getRequiredStringMap('followup_actions.knowledge');
}
private function getRequiredInt(string $key): int
{
$value = $this->requiredValue($key);
@@ -325,6 +305,65 @@ final class AgentRunnerConfig
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be a non-empty string.', $key));
}
private function getOptionalBool(string $key, bool $default): bool
{
$value = $this->optionalValue($key);
if ($value === null) {
return $default;
}
if (is_bool($value)) {
return $value;
}
if (is_scalar($value)) {
$normalized = strtolower(trim((string) $value));
if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) {
return true;
}
if (in_array($normalized, ['0', 'false', 'no', 'off'], true)) {
return false;
}
}
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be boolean.', $key));
}
/**
* @return string[]
*/
private function getOptionalStringList(string $key): array
{
$value = $this->optionalValue($key);
if ($value === null) {
return [];
}
if (!is_array($value)) {
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be a list.', $key));
}
$out = [];
foreach ($value as $item) {
if (!is_scalar($item)) {
continue;
}
$item = trim((string) $item);
if ($item !== '') {
$out[] = $item;
}
}
return array_values(array_unique($out));
}
/**
* @return string[]
*/
@@ -404,39 +443,6 @@ final class AgentRunnerConfig
return $out;
}
/**
* @return array<string, string>
*/
private function getRequiredStringMap(string $key): array
{
$value = $this->requiredValue($key);
if (!is_array($value)) {
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be a string map.', $key));
}
$out = [];
foreach ($value as $mapKey => $mapValue) {
if (!is_scalar($mapKey) || !is_scalar($mapValue)) {
continue;
}
$mapKey = trim((string) $mapKey);
$mapValue = trim((string) $mapValue);
if ($mapKey !== '' && $mapValue !== '') {
$out[$mapKey] = $mapValue;
}
}
if ($out === []) {
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must contain at least one valid entry.', $key));
}
return $out;
}
/**
* @return array<string, string>
*/
@@ -787,6 +793,19 @@ final class AgentRunnerConfig
return $this->getRequiredStringList('shop_prompt.context_usage.referential_terms');
}
public function isShopQueryCurrentInputPreservationEnabled(): bool
{
return $this->getOptionalBool('shop_prompt.current_input_preservation.enabled', true);
}
/**
* @return string[]
*/
public function getShopQueryCurrentInputPreservationTerms(): array
{
return $this->getOptionalStringList('shop_prompt.current_input_preservation.terms');
}
public function getShopPromptIntro(): string
{
return $this->getRequiredString('shop_prompt.intro');