- QueryEmbedder: vector of a search phrase cached 30 days (cache bin materio_ai), model given search_timeout seconds (1 by default, new setting, update 11001), left alone 60 s after a failure (ModelPausedException, not logged). - NeighbourSearch honours the enabled setting: the search called the model even when materio_ai was switched off. - materio_ai_cron() loads the model with the normal timeout: after a restart, loading (2.9 s) exceeds the search delay and Ollama drops it, so searches alone would never load it. Ultimate cron job exported. - On any model failure the search answers with the keyword results only. - QueryEmbedderTest: cache, delay, pause, cache during the pause, warm-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ShDspHaZGwHoRZCsPBJzsM
71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?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;
|
|
}
|
|
|
|
/**
|
|
* Adds the search timeout setting (H8).
|
|
*/
|
|
function materio_ai_update_11001(): void {
|
|
$config = \Drupal::configFactory()->getEditable('materio_ai.settings');
|
|
if ($config->get('search_timeout') === NULL) {
|
|
$config->set('search_timeout', 1.0)->save(TRUE);
|
|
}
|
|
}
|