• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-solver / 13281246435

12 Feb 2025 08:36AM UTC coverage: 88.172% (+0.1%) from 88.036%
13281246435

push

github

web-flow
Merge pull request #299 from eliashaeussler/feature/generic-list-models

[!!!][FEATURE] Require solution providers to list available models

31 of 32 new or added lines in 5 files covered. (96.88%)

902 of 1023 relevant lines covered (88.17%)

2.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.77
/Classes/Command/ListModelsCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "solver".
7
 *
8
 * Copyright (C) 2023-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3Solver\Command;
25

26
use EliasHaeussler\Typo3Solver\Configuration;
27
use EliasHaeussler\Typo3Solver\ProblemSolving;
28
use Symfony\Component\Console;
29

30
/**
31
 * ListModelsCommand
32
 *
33
 * @author Elias Häußler <elias@haeussler.dev>
34
 * @license GPL-2.0-or-later
35
 */
36
final class ListModelsCommand extends Console\Command\Command
37
{
38
    private readonly ProblemSolving\Solution\Provider\SolutionProvider $solutionProvider;
39

40
    public function __construct(
2✔
41
        private readonly Configuration\Configuration $configuration,
42
        ProblemSolving\Solution\Provider\SolutionProvider $solutionProvider = null,
43
    ) {
44
        parent::__construct('solver:list-models');
2✔
45

46
        $this->solutionProvider = $solutionProvider ?? $this->configuration->getProvider();
2✔
47
    }
48

49
    protected function configure(): void
2✔
50
    {
51
        $this->addOption(
2✔
52
            'all',
2✔
53
            'a',
2✔
54
            Console\Input\InputOption::VALUE_NONE,
2✔
55
            'List all available models, even those which cannot be used',
2✔
56
        );
2✔
57
    }
58

59
    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
2✔
60
    {
61
        $io = new Console\Style\SymfonyStyle($input, $output);
2✔
62
        $listAll = $input->getOption('all');
2✔
63

64
        // Retrieve models via solution provider
65
        $modelListResponse = $this->solutionProvider->listModels($listAll);
2✔
66

67
        if ($listAll) {
2✔
68
            $io->title('Available AI models');
1✔
69
        } else {
70
            $io->title('Supported AI models');
1✔
71
        }
72

73
        // Map responses to model IDs
74
        $models = \array_map(
2✔
75
            $this->decorateModel(...),
2✔
76
            $modelListResponse,
2✔
77
        );
2✔
78

79
        \sort($models);
2✔
80

81
        $io->listing($models);
2✔
82

83
        if ($listAll) {
2✔
84
            $io->writeln('💡 <comment>Only a limited set of models can be used with this extension.</comment>');
1✔
85
            $io->newLine();
1✔
86
        }
87

88
        return self::SUCCESS;
2✔
89
    }
90

91
    private function decorateModel(ProblemSolving\Solution\Provider\Model\AiModel $model): string
2✔
92
    {
93
        if ($model->createdAt === null) {
2✔
NEW
94
            return $model->name;
×
95
        }
96

97
        return \sprintf('%s <fg=gray>(created at %s)</>', $model->name, $model->createdAt->format('d/m/Y'));
2✔
98
    }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc