mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-06-22 02:21:39 +00:00
Allow to add selectors to ai model selects and only show models supporting structured output for AI extractor
This commit is contained in:
parent
9d389309fc
commit
368dd14785
3 changed files with 47 additions and 22 deletions
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Form\Settings;
|
||||
|
||||
use Symfony\AI\Platform\Capability;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
|
|
@ -50,11 +51,20 @@ final class AiModelsType extends AbstractType
|
|||
//The target label of the platform select, which is used to filter the models for the selected platform.
|
||||
$resolver->setRequired('platform_selector');
|
||||
$resolver->setAllowedTypes('platform_selector', 'string');
|
||||
|
||||
//Only show models, that have the given capability. This is used to only show models that support structured output for the AI extractor settings.
|
||||
$resolver->setDefault('filter_capability', null);
|
||||
$resolver->setAllowedTypes('filter_capability', ['null', Capability::class]);
|
||||
}
|
||||
|
||||
public function finishView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars['attr']['data-url-template'] = $this->urlGenerator->generate('typeahead_ai_models', ['platform' => '__PLATFORM__']);
|
||||
$urlOptions = ['platform' => '__PLATFORM__'];
|
||||
if ($options['filter_capability'] !== null) {
|
||||
$urlOptions['capability'] = $options['filter_capability']->value;
|
||||
}
|
||||
|
||||
$view->vars['attr']['data-url-template'] = $this->urlGenerator->generate('typeahead_ai_models', $urlOptions);
|
||||
$view->vars['attr']['data-controller'] = 'elements--ai-model-autocomplete';
|
||||
|
||||
$view->vars['attr']['data-platform-selector'] = $options['platform_selector'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue