patch 9
This commit is contained in:
@@ -156,62 +156,62 @@ final class PromptBuilderConfig
|
||||
|
||||
public function getCharsPerToken(): int
|
||||
{
|
||||
return $this->getInt('budget.chars_per_token', 4);
|
||||
return $this->getRequiredInt('budget.chars_per_token');
|
||||
}
|
||||
|
||||
public function getHistoryPaddingChars(): int
|
||||
{
|
||||
return $this->getInt('budget.history_padding_chars', 400);
|
||||
return $this->getRequiredInt('budget.history_padding_chars');
|
||||
}
|
||||
|
||||
public function getOutputReserveRatio(): float
|
||||
{
|
||||
return $this->getFloat('budget.output_reserve_ratio', 0.25);
|
||||
return $this->getRequiredFloat('budget.output_reserve_ratio');
|
||||
}
|
||||
|
||||
public function getOutputReserveMinTokens(): int
|
||||
{
|
||||
return $this->getInt('budget.output_reserve_min_tokens', 768);
|
||||
return $this->getRequiredInt('budget.output_reserve_min_tokens');
|
||||
}
|
||||
|
||||
public function getOutputReserveMaxTokens(): int
|
||||
{
|
||||
return $this->getInt('budget.output_reserve_max_tokens', 6000);
|
||||
return $this->getRequiredInt('budget.output_reserve_max_tokens');
|
||||
}
|
||||
|
||||
public function getSafetyReserveRatio(): float
|
||||
{
|
||||
return $this->getFloat('budget.safety_reserve_ratio', 0.05);
|
||||
return $this->getRequiredFloat('budget.safety_reserve_ratio');
|
||||
}
|
||||
|
||||
public function getSafetyReserveMinTokens(): int
|
||||
{
|
||||
return $this->getInt('budget.safety_reserve_min_tokens', 256);
|
||||
return $this->getRequiredInt('budget.safety_reserve_min_tokens');
|
||||
}
|
||||
|
||||
public function getSafetyReserveMaxTokens(): int
|
||||
{
|
||||
return $this->getInt('budget.safety_reserve_max_tokens', 1024);
|
||||
return $this->getRequiredInt('budget.safety_reserve_max_tokens');
|
||||
}
|
||||
|
||||
public function getMinPromptBudgetTokens(): int
|
||||
{
|
||||
return $this->getInt('budget.min_prompt_budget_tokens', 1024);
|
||||
return $this->getRequiredInt('budget.min_prompt_budget_tokens');
|
||||
}
|
||||
|
||||
public function getMaxShopResultsInPrompt(): int
|
||||
{
|
||||
return $this->getInt('shop_results.max_results_in_prompt', 24);
|
||||
return $this->getRequiredInt('shop_results.max_results_in_prompt');
|
||||
}
|
||||
|
||||
public function getDetailedShopResultsMaxCount(): int
|
||||
{
|
||||
return $this->getInt('shop_results.detailed_max_count', 5);
|
||||
return $this->getRequiredInt('shop_results.detailed_max_count');
|
||||
}
|
||||
|
||||
public function getTechnicalProductKeywordMatchThreshold(): int
|
||||
{
|
||||
return $this->getInt('technical_product_keyword_match_threshold', 2);
|
||||
return $this->getRequiredInt('technical_product_keyword_match_threshold');
|
||||
}
|
||||
|
||||
private function getInt(string $path, int $default): int
|
||||
@@ -228,6 +228,28 @@ final class PromptBuilderConfig
|
||||
return is_numeric($value) ? (float) $value : $default;
|
||||
}
|
||||
|
||||
private function getRequiredInt(string $path): int
|
||||
{
|
||||
$value = $this->getRequiredValue($path);
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
throw new \InvalidArgumentException(sprintf('RetrieX prompt config value "%s" must be numeric.', $path));
|
||||
}
|
||||
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
private function getRequiredFloat(string $path): float
|
||||
{
|
||||
$value = $this->getRequiredValue($path);
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
throw new \InvalidArgumentException(sprintf('RetrieX prompt config value "%s" must be numeric.', $path));
|
||||
}
|
||||
|
||||
return (float) $value;
|
||||
}
|
||||
|
||||
private function getString(string $path, string $default): string
|
||||
{
|
||||
$value = $this->getValue($path, $default);
|
||||
@@ -292,6 +314,21 @@ final class PromptBuilderConfig
|
||||
return $current;
|
||||
}
|
||||
|
||||
private function getRequiredValue(string $path): mixed
|
||||
{
|
||||
$current = $this->config;
|
||||
|
||||
foreach (explode('.', $path) as $segment) {
|
||||
if (!is_array($current) || !array_key_exists($segment, $current)) {
|
||||
throw new \InvalidArgumentException(sprintf('Missing required RetrieX prompt config path "%s".', $path));
|
||||
}
|
||||
|
||||
$current = $current[$segment];
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
public function getSystemSectionLabel(): string
|
||||
{
|
||||
return $this->getString('sections.system_label', 'SYSTEM');
|
||||
|
||||
Reference in New Issue
Block a user