Backup #1426
| ID | 1426 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Application/PipelineStepService.php |
| Version | 7 |
| Typ |
modified |
| Größe | 4.5 KB |
| Hash | 0e0e010a460984e5f266bcac4310a7f22191f60295a833cf4592c544f73788de |
| Datum | 2025-12-25 16:59:24 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Application;
// @responsibility: Service für Pipeline-Step-Operationen (Toggle, Konfiguration)
use Domain\Repository\PipelineConfigRepositoryInterface;
use Domain\Repository\PipelineStepRepositoryInterface;
use Infrastructure\AI\ModelRegistry;
use Infrastructure\Config\PipelineStepConfig;
final class PipelineStepService
{
public function __construct(
private PipelineConfigRepositoryInterface $configRepository,
private PipelineStepRepositoryInterface $stepRepository,
private ModelRegistry $modelRegistry
) {
}
/**
* Toggle a step's enabled status.
*
* @return bool True if toggled successfully
*/
public function toggleStep(int $pipelineId, int $stepId): bool
{
$pipeline = $this->configRepository->findById($pipelineId);
if ($pipeline === null) {
return false;
}
$steps = $this->stepRepository->findSteps($pipelineId);
foreach ($steps as $step) {
if ((int) $step['id'] === $stepId) {
$this->stepRepository->updateStep($stepId, [
'enabled' => $step['enabled'] ? 0 : 1,
]);
return true;
}
}
return false;
}
/**
* Update the model for a step.
*
* @return array{success: bool, error?: string, model?: string, label?: string}
*/
public function updateModel(int $pipelineId, int $stepId, string $model): array
{
$pipeline = $this->configRepository->findById($pipelineId);
if ($pipeline === null) {
return ['success' => false, 'error' => 'Pipeline nicht gefunden'];
}
$model = trim($model);
if ($model === '' || !$this->modelRegistry->isValid($model)) {
return ['success' => false, 'error' => 'Ungültiges Modell'];
}
$steps = $this->stepRepository->findSteps($pipelineId);
foreach ($steps as $step) {
if ((int) $step['id'] === $stepId) {
$config = $step['config'] ?? [];
// Determine provider from model
$provider = $this->modelRegistry->isLocal($model) ? 'ollama' : 'anthropic';
// Update config with new model
$config['model'] = $this->modelRegistry->isLocal($model)
? substr($model, 7) // Remove 'ollama:' prefix
: $model;
$config['provider'] = $provider;
$this->stepRepository->updateStep($stepId, [
'config' => $config,
]);
return [
'success' => true,
'model' => $model,
'label' => $this->modelRegistry->getLabel($model),
];
}
}
return ['success' => false, 'error' => 'Schritt nicht gefunden'];
}
/**
* Update the collection for a step.
*
* @return array{success: bool, error?: string, collection?: string, label?: string}
*/
public function updateCollection(int $pipelineId, int $stepId, string $collection): array
{
$pipeline = $this->repository->findById($pipelineId);
if ($pipeline === null) {
return ['success' => false, 'error' => 'Pipeline nicht gefunden'];
}
$collection = trim($collection);
$validCollections = array_keys(PipelineStepConfig::getCollections());
if ($collection === '' || !in_array($collection, $validCollections, true)) {
return ['success' => false, 'error' => 'Ungültige Collection'];
}
foreach ($pipeline['steps'] as $step) {
if ((int) $step['id'] === $stepId) {
$config = $step['config'] ?? [];
$config['collection'] = $collection;
$this->repository->updateStep($stepId, [
'config' => $config,
]);
$collections = PipelineStepConfig::getCollections();
return [
'success' => true,
'collection' => $collection,
'label' => $collections[$collection] ?? $collection,
];
}
}
return ['success' => false, 'error' => 'Schritt nicht gefunden'];
}
/**
* Create default steps for a new pipeline.
*/
public function createDefaultSteps(int $pipelineId): void
{
foreach (PipelineStepConfig::getDefaultSteps() as $step) {
$this->repository->addStep($pipelineId, $step);
}
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1429 |
8 |
modified |
4.6 KB |
2025-12-25 16:59 |
| 1426 |
7 |
modified |
4.5 KB |
2025-12-25 16:59 |
| 1418 |
6 |
modified |
4.5 KB |
2025-12-25 16:59 |
| 1415 |
5 |
modified |
4.4 KB |
2025-12-25 16:59 |
| 1414 |
4 |
modified |
4.3 KB |
2025-12-25 16:58 |
| 1301 |
3 |
modified |
4.2 KB |
2025-12-25 13:28 |
| 1300 |
2 |
modified |
4.2 KB |
2025-12-25 13:28 |
| 824 |
1 |
modified |
4.1 KB |
2025-12-23 08:09 |
← Zurück zur Übersicht