first update to external config values
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin;
|
||||
|
||||
use App\Config\ModelGenerationDefaultsConfig;
|
||||
use App\Entity\ModelGenerationConfig;
|
||||
use App\Knowledge\Retrieval\NdjsonHybridRetriever;
|
||||
use App\Repository\ModelGenerationConfigRepository;
|
||||
@@ -17,6 +18,7 @@ final class ModelGenerationConfigAdminService
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly ModelGenerationConfigManager $manager,
|
||||
private readonly NdjsonHybridRetriever $retriever,
|
||||
private readonly ModelGenerationDefaultsConfig $defaults,
|
||||
) {}
|
||||
|
||||
public function list(): array
|
||||
@@ -36,15 +38,15 @@ final class ModelGenerationConfigAdminService
|
||||
$config = new ModelGenerationConfig(
|
||||
modelName: $modelName,
|
||||
version: $version,
|
||||
stream: (bool)($data['stream'] ?? false),
|
||||
temperature: (float)($data['temperature'] ?? 0.7),
|
||||
topK: (int)($data['top_k'] ?? 40),
|
||||
topP: (float)($data['top_p'] ?? 0.9),
|
||||
repeatPenalty: (float)($data['repeat_penalty'] ?? 1.1),
|
||||
numCtx: (int)($data['num_ctx'] ?? 4096),
|
||||
stream: (bool)($data['stream'] ?? $this->defaults->isStream()),
|
||||
temperature: (float)($data['temperature'] ?? $this->defaults->getTemperature()),
|
||||
topK: (int)($data['top_k'] ?? $this->defaults->getTopK()),
|
||||
topP: (float)($data['top_p'] ?? $this->defaults->getTopP()),
|
||||
repeatPenalty: (float)($data['repeat_penalty'] ?? $this->defaults->getRepeatPenalty()),
|
||||
numCtx: (int)($data['num_ctx'] ?? $this->defaults->getNumCtx()),
|
||||
active: false,
|
||||
retrievalMaxChunks: (int)($data['retrieval_max_chunks'] ?? 25),
|
||||
retrievalVectorTopK: (int)($data['retrieval_vector_top_k'] ?? 25),
|
||||
retrievalMaxChunks: (int)($data['retrieval_max_chunks'] ?? $this->defaults->getRetrievalMaxChunks()),
|
||||
retrievalVectorTopK: (int)($data['retrieval_vector_top_k'] ?? $this->defaults->getRetrievalVectorTopK()),
|
||||
);
|
||||
|
||||
$this->em->persist($config);
|
||||
@@ -61,7 +63,7 @@ final class ModelGenerationConfigAdminService
|
||||
public function delete(ModelGenerationConfig $config): void
|
||||
{
|
||||
if ($config->isActive()) {
|
||||
throw new \RuntimeException('Aktive Konfiguration kann nicht gelöscht werden.');
|
||||
throw new \RuntimeException('Aktive Konfiguration kann nicht geloescht werden.');
|
||||
}
|
||||
|
||||
$this->em->remove($config);
|
||||
@@ -74,7 +76,7 @@ final class ModelGenerationConfigAdminService
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->retriever->retrieveDebug($prompt,$config);
|
||||
return $this->retriever->retrieveDebug($prompt, $config);
|
||||
}
|
||||
|
||||
private function requireString(mixed $value, string $field): string
|
||||
@@ -84,4 +86,4 @@ final class ModelGenerationConfigAdminService
|
||||
}
|
||||
return trim($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Config\ModelGenerationDefaultsConfig;
|
||||
use App\Entity\ModelGenerationConfig;
|
||||
use App\Repository\ModelGenerationConfigRepository;
|
||||
|
||||
final readonly class ModelGenerationConfigProvider
|
||||
{
|
||||
public function __construct(
|
||||
private ModelGenerationConfigRepository $repository
|
||||
)
|
||||
{
|
||||
private ModelGenerationConfigRepository $repository,
|
||||
private ModelGenerationDefaultsConfig $defaults,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getActiveForModel(): ModelGenerationConfig
|
||||
@@ -23,19 +24,18 @@ final readonly class ModelGenerationConfigProvider
|
||||
return $config;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Safe Enterprise Default Fallback
|
||||
// ------------------------------
|
||||
return new ModelGenerationConfig(
|
||||
modelName: 'mto-model',
|
||||
modelName: $this->defaults->getModelName(),
|
||||
version: 0,
|
||||
stream: false,
|
||||
temperature: 0.1,
|
||||
topK: 20,
|
||||
topP: 0.8,
|
||||
repeatPenalty: 1.05,
|
||||
numCtx: 4096,
|
||||
active: false
|
||||
stream: $this->defaults->isStream(),
|
||||
temperature: $this->defaults->getTemperature(),
|
||||
topK: $this->defaults->getTopK(),
|
||||
topP: $this->defaults->getTopP(),
|
||||
repeatPenalty: $this->defaults->getRepeatPenalty(),
|
||||
numCtx: $this->defaults->getNumCtx(),
|
||||
active: false,
|
||||
retrievalMaxChunks: $this->defaults->getRetrievalMaxChunks(),
|
||||
retrievalVectorTopK: $this->defaults->getRetrievalVectorTopK(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,4 +45,4 @@ final readonly class ModelGenerationConfigProvider
|
||||
|
||||
return max(512, $numCtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user