patch 11
This commit is contained in:
@@ -39,43 +39,6 @@ final class AgentRunnerConfig
|
||||
return $this->getRequiredString('optimized_shop_query_trim_characters');
|
||||
}
|
||||
|
||||
private function getInt(string $key, int $default): int
|
||||
{
|
||||
$value = $this->value($key, $default);
|
||||
|
||||
return is_numeric($value) ? (int) $value : $default;
|
||||
}
|
||||
|
||||
private function getBool(string $key, bool $default): bool
|
||||
{
|
||||
$value = $this->value($key, $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;
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
private function getString(string $key, string $default): string
|
||||
{
|
||||
$value = $this->value($key, $default);
|
||||
|
||||
return is_string($value) && $value !== '' ? $value : $default;
|
||||
}
|
||||
|
||||
private function getRequiredInt(string $key): int
|
||||
{
|
||||
$value = $this->requiredValue($key);
|
||||
@@ -233,49 +196,6 @@ final class AgentRunnerConfig
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $default
|
||||
* @return string[]
|
||||
*/
|
||||
private function getStringList(string $key, array $default): array
|
||||
{
|
||||
$value = $this->value($key, $default);
|
||||
|
||||
if (!is_array($value)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
|
||||
foreach ($value as $item) {
|
||||
if (!is_scalar($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = trim((string) $item);
|
||||
|
||||
if ($item !== '') {
|
||||
$out[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $out !== [] ? $out : $default;
|
||||
}
|
||||
|
||||
private function value(string $key, mixed $default): mixed
|
||||
{
|
||||
$current = $this->config;
|
||||
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (!is_array($current) || !array_key_exists($segment, $current)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$current = $current[$segment];
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
private function requiredValue(string $key): mixed
|
||||
{
|
||||
|
||||
@@ -48,6 +48,35 @@ final class CommerceQueryParserConfig
|
||||
return $this->stringList('filter_search_tokens');
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function whitespacePreservingStringList(string $path): array
|
||||
{
|
||||
$value = $this->value($path);
|
||||
if (!is_array($value)) {
|
||||
throw $this->invalid($path, 'must be a list of non-empty strings');
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($value as $item) {
|
||||
if (!is_scalar($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = (string) $item;
|
||||
if (trim($item) === '' || in_array($item, $out, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$out[] = $item;
|
||||
}
|
||||
|
||||
if ($out === []) {
|
||||
throw $this->invalid($path, 'must contain at least one non-empty string');
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
public function getSearchTokenCorrections(): array
|
||||
{
|
||||
@@ -73,13 +102,13 @@ final class CommerceQueryParserConfig
|
||||
/** @return string[] */
|
||||
public function getNormalizationSearch(): array
|
||||
{
|
||||
return $this->stringList('normalization.search', true);
|
||||
return $this->whitespacePreservingStringList('normalization.search');
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
public function getNormalizationReplace(): array
|
||||
{
|
||||
return $this->stringList('normalization.replace', true);
|
||||
return $this->whitespacePreservingStringList('normalization.replace');
|
||||
}
|
||||
|
||||
public function getPromptSanitizePattern(): string
|
||||
@@ -249,7 +278,7 @@ final class CommerceQueryParserConfig
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function stringList(string $path, bool $preserveWhitespace = false): array
|
||||
private function stringList(string $path): array
|
||||
{
|
||||
$value = $this->value($path);
|
||||
if (!is_array($value)) {
|
||||
@@ -262,12 +291,9 @@ final class CommerceQueryParserConfig
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = (string) $item;
|
||||
if (!$preserveWhitespace) {
|
||||
$item = trim($item);
|
||||
}
|
||||
$item = trim((string) $item);
|
||||
|
||||
if (trim($item) === '' || in_array($item, $out, true)) {
|
||||
if ($item === '' || in_array($item, $out, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ namespace App\Config;
|
||||
final readonly class ModelGenerationDefaultsConfig
|
||||
{
|
||||
public function __construct(
|
||||
private string $modelName = 'mto-model',
|
||||
private bool $stream = false,
|
||||
private float $temperature = 0.1,
|
||||
private int $topK = 20,
|
||||
private float $topP = 0.8,
|
||||
private float $repeatPenalty = 1.05,
|
||||
private int $numCtx = 4096,
|
||||
private int $retrievalMaxChunks = 25,
|
||||
private int $retrievalVectorTopK = 25,
|
||||
private string $modelName,
|
||||
private bool $stream,
|
||||
private float $temperature,
|
||||
private int $topK,
|
||||
private float $topP,
|
||||
private float $repeatPenalty,
|
||||
private int $numCtx,
|
||||
private int $retrievalMaxChunks,
|
||||
private int $retrievalVectorTopK,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user