materio_ai: embedding table and storage service (V3)

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 20:16:37 +01:00
co-authored by Claude Opus 5.5
parent 45f21b2e49
commit 86ca518c6c
3 changed files with 202 additions and 0 deletions
@@ -0,0 +1,60 @@
<?php
/**
* @file
* Install, update and uninstall functions for materio_ai.
*/
declare(strict_types=1);
/**
* Implements hook_schema().
*/
function materio_ai_schema(): array {
$schema['materio_ai_embedding'] = [
'description' => 'Vector of each node translation, computed by the embedding model.',
'fields' => [
'nid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Node ID.',
],
'langcode' => [
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
'description' => 'Language of the vectorized translation.',
],
'model' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'description' => 'Model that computed the vector, for example bge-m3:567m.',
],
'text_hash' => [
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'description' => 'SHA-256 of the vectorized text, to skip unchanged texts.',
],
'vector' => [
'type' => 'blob',
'size' => 'normal',
'not null' => TRUE,
'description' => 'Vector as little-endian 32-bit floats.',
],
'changed' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Unix timestamp of the last vectorization.',
],
],
'primary key' => ['nid', 'langcode'],
'indexes' => [
'model' => ['model'],
],
];
return $schema;
}