materio_ai: module skeleton, settings and schema (V1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShDspHaZGwHoRZCsPBJzsM
This commit is contained in:
2026-11-16 19:35:09 +01:00
co-authored by Claude Opus 5.5
parent 6072f70553
commit 890c80eb12
10 changed files with 146 additions and 0 deletions
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace Drupal\materio_ai\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Settings of the embedding service.
*/
final class SettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return 'materio_ai_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames(): array {
return ['materio_ai.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form['enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enabled'),
'#description' => $this->t('When disabled, no text is sent to the model and nothing is vectorized.'),
'#config_target' => 'materio_ai.settings:enabled',
];
$form['url'] = [
'#type' => 'url',
'#title' => $this->t('Embedding service URL'),
'#description' => $this->t('Ollama base URL, for example http://ollama:11434. Usually overridden in settings.php per environment.'),
'#required' => TRUE,
'#config_target' => 'materio_ai.settings:url',
];
$form['model'] = [
'#type' => 'textfield',
'#title' => $this->t('Model'),
'#required' => TRUE,
'#config_target' => 'materio_ai.settings:model',
];
$form['dimension'] = [
'#type' => 'number',
'#title' => $this->t('Vector dimension'),
'#min' => 1,
'#required' => TRUE,
'#config_target' => 'materio_ai.settings:dimension',
];
$form['timeout'] = [
'#type' => 'number',
'#title' => $this->t('Timeout (seconds)'),
'#min' => 1,
'#required' => TRUE,
'#config_target' => 'materio_ai.settings:timeout',
];
$form['num_thread'] = [
'#type' => 'number',
'#title' => $this->t('Threads per call'),
'#description' => $this->t('Sent as options.num_thread: Ollama does not see the CPU limit of its container.'),
'#min' => 1,
'#required' => TRUE,
'#config_target' => 'materio_ai.settings:num_thread',
];
return parent::buildForm($form, $form_state);
}
}