first update to external config values

This commit is contained in:
team 1
2026-04-24 13:13:56 +02:00
parent 868f9a8857
commit 26ec0afc5c
11 changed files with 292 additions and 187 deletions

View File

@@ -6,64 +6,101 @@ namespace App\Config;
final class PromptBuilderConfig
{
/**
* @param array<string, mixed> $config
*/
public function __construct(
private readonly array $config = [],
) {
}
public function getCharsPerToken(): int
{
return 4;
return $this->getInt('budget.chars_per_token', 4);
}
public function getHistoryPaddingChars(): int
{
return 400;
return $this->getInt('budget.history_padding_chars', 400);
}
public function getOutputReserveRatio(): float
{
return 0.25;
return $this->getFloat('budget.output_reserve_ratio', 0.25);
}
public function getOutputReserveMinTokens(): int
{
return 768;
return $this->getInt('budget.output_reserve_min_tokens', 768);
}
public function getOutputReserveMaxTokens(): int
{
return 6000;
return $this->getInt('budget.output_reserve_max_tokens', 6000);
}
public function getSafetyReserveRatio(): float
{
return 0.05;
return $this->getFloat('budget.safety_reserve_ratio', 0.05);
}
public function getSafetyReserveMinTokens(): int
{
return 256;
return $this->getInt('budget.safety_reserve_min_tokens', 256);
}
public function getSafetyReserveMaxTokens(): int
{
return 1024;
return $this->getInt('budget.safety_reserve_max_tokens', 1024);
}
public function getMinPromptBudgetTokens(): int
{
return 1024;
return $this->getInt('budget.min_prompt_budget_tokens', 1024);
}
public function getMaxShopResultsInPrompt(): int
{
return 24;
return $this->getInt('shop_results.max_results_in_prompt', 24);
}
public function getDetailedShopResultsMaxCount(): int
{
return 5;
return $this->getInt('shop_results.detailed_max_count', 5);
}
public function getTechnicalProductKeywordMatchThreshold(): int
{
return 2;
return $this->getInt('technical_product_keyword_match_threshold', 2);
}
private function getInt(string $path, int $default): int
{
$value = $this->getValue($path, $default);
return is_numeric($value) ? (int) $value : $default;
}
private function getFloat(string $path, float $default): float
{
$value = $this->getValue($path, $default);
return is_numeric($value) ? (float) $value : $default;
}
private function getValue(string $path, mixed $default): mixed
{
$current = $this->config;
foreach (explode('.', $path) as $segment) {
if (!is_array($current) || !array_key_exists($segment, $current)) {
return $default;
}
$current = $current[$segment];
}
return $current;
}
public function getSystemSectionLabel(): string