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:
@@ -122,6 +122,7 @@ module:
|
||||
maillog: 0
|
||||
masquerade: 0
|
||||
materio_admin: 0
|
||||
materio_ai: 0
|
||||
materio_commerce: 0
|
||||
materio_decoupled: 0
|
||||
materio_expo: 0
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
_core:
|
||||
default_config_hash: __uY4VMv6UzzHCHq1eTjbhXofXp1BTtuR5VjcV_MHYM
|
||||
enabled: false
|
||||
url: 'http://ollama:11434'
|
||||
model: 'bge-m3:567m'
|
||||
dimension: 1024
|
||||
timeout: 10
|
||||
num_thread: 4
|
||||
@@ -0,0 +1,12 @@
|
||||
# Désactivé à l'installation : le module ne fait rien tant que « enabled » est faux.
|
||||
enabled: false
|
||||
# Service Ollama. En local : conteneur « ollama » du docker-compose.
|
||||
# Sur le serveur : à surcharger dans settings.php (CT-materio_embed sur le pont privé).
|
||||
url: 'http://ollama:11434'
|
||||
model: 'bge-m3:567m'
|
||||
dimension: 1024
|
||||
# Délai maximal d'un appel au modèle, en secondes.
|
||||
timeout: 10
|
||||
# Threads de calcul envoyés à chaque appel (options.num_thread) : Ollama ne voit pas
|
||||
# la limite de CPU du conteneur, sans ce réglage il lance trop de threads (mesure M2).
|
||||
num_thread: 4
|
||||
@@ -0,0 +1,22 @@
|
||||
materio_ai.settings:
|
||||
type: config_object
|
||||
label: 'materiO AI settings'
|
||||
mapping:
|
||||
enabled:
|
||||
type: boolean
|
||||
label: 'Enabled'
|
||||
url:
|
||||
type: uri
|
||||
label: 'Embedding service URL'
|
||||
model:
|
||||
type: string
|
||||
label: 'Model'
|
||||
dimension:
|
||||
type: integer
|
||||
label: 'Vector dimension'
|
||||
timeout:
|
||||
type: integer
|
||||
label: 'Timeout (seconds)'
|
||||
num_thread:
|
||||
type: integer
|
||||
label: 'Threads per call'
|
||||
@@ -0,0 +1,6 @@
|
||||
name: 'materiO AI'
|
||||
type: module
|
||||
description: 'Recherche par le sens : vectorisation des fiches avec un modèle d''embedding (bge-m3).'
|
||||
core_version_requirement: ^10.3 || ^11
|
||||
package: 'Materio'
|
||||
configure: materio_ai.settings
|
||||
@@ -0,0 +1,5 @@
|
||||
materio_ai.settings:
|
||||
title: 'materiO AI'
|
||||
description: 'Embedding service for the semantic search.'
|
||||
route_name: materio_ai.settings
|
||||
parent: system.admin_config_search
|
||||
@@ -0,0 +1,4 @@
|
||||
administer materio ai:
|
||||
title: 'Administer materiO AI'
|
||||
description: 'Configure the embedding service used by the semantic search.'
|
||||
restrict access: true
|
||||
@@ -0,0 +1,7 @@
|
||||
materio_ai.settings:
|
||||
path: '/admin/config/search/materio-ai'
|
||||
defaults:
|
||||
_form: '\Drupal\materio_ai\Form\SettingsForm'
|
||||
_title: 'materiO AI'
|
||||
requirements:
|
||||
_permission: 'administer materio ai'
|
||||
@@ -0,0 +1,4 @@
|
||||
services:
|
||||
logger.channel.materio_ai:
|
||||
parent: logger.channel_base
|
||||
arguments: ['materio_ai']
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user