first update to external config values
This commit is contained in:
@@ -6,24 +6,32 @@ namespace App\Config;
|
||||
|
||||
final class AgentRunnerConfig
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly array $config = [],
|
||||
) {
|
||||
}
|
||||
|
||||
public function getCommerceHistoryBudgetChars(): int
|
||||
{
|
||||
return 1000;
|
||||
return $this->getInt('commerce_history_budget_chars', 1000);
|
||||
}
|
||||
|
||||
public function getProductSearchKnowledgeChunkLimit(): int
|
||||
{
|
||||
return 6;
|
||||
return $this->getInt('product_search_knowledge_chunk_limit', 6);
|
||||
}
|
||||
|
||||
public function getAdvisoryProductSearchKnowledgeChunkLimit(): int
|
||||
{
|
||||
return 9;
|
||||
return $this->getInt('advisory_product_search_knowledge_chunk_limit', 9);
|
||||
}
|
||||
|
||||
public function getOptimizedShopQueryPrefixPattern(): string
|
||||
{
|
||||
return '/^(?:keywords?|suchquery|search\s*query|query)\s*:\s*/iu';
|
||||
return $this->getString('optimized_shop_query_prefix_pattern', '/^(?:keywords?|suchquery|search\\s*query|query)\\s*:\\s*/iu');
|
||||
}
|
||||
|
||||
public function getOptimizedShopQueryTrimCharacters(): string
|
||||
@@ -31,6 +39,20 @@ final class AgentRunnerConfig
|
||||
return " \t\n\r\0\x0B\"'`";
|
||||
}
|
||||
|
||||
private function getInt(string $key, int $default): int
|
||||
{
|
||||
$value = $this->config[$key] ?? $default;
|
||||
|
||||
return is_numeric($value) ? (int) $value : $default;
|
||||
}
|
||||
|
||||
private function getString(string $key, string $default): string
|
||||
{
|
||||
$value = $this->config[$key] ?? $default;
|
||||
|
||||
return is_string($value) && $value !== '' ? $value : $default;
|
||||
}
|
||||
|
||||
public function getEmptyPromptMessage(): string
|
||||
{
|
||||
return '❌ Empty prompt.';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,19 +6,26 @@ namespace App\Config;
|
||||
|
||||
final class SearchRepairConfig
|
||||
{
|
||||
public function __construct(
|
||||
private readonly bool $enabled = true,
|
||||
private readonly int $maxRepairQueries = 3,
|
||||
private readonly int $minPrimaryResultsWithoutRepair = 2,
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
public function getMaxRepairQueries(): int
|
||||
{
|
||||
return 3;
|
||||
return $this->maxRepairQueries;
|
||||
}
|
||||
|
||||
public function getMinPrimaryResultsWithoutRepair(): int
|
||||
{
|
||||
return 2;
|
||||
return $this->minPrimaryResultsWithoutRepair;
|
||||
}
|
||||
|
||||
public function getTopProductLogLimit(): int
|
||||
|
||||
Reference in New Issue
Block a user