Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ai
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ai
Merge requests
!141
Auto-choose tokenizer
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Auto-choose tokenizer
issue/ai-3477973:3477973-dynamically-load-tokenizer
into
1.1.x
Overview
0
Commits
10
Pipelines
11
Changes
5
Open
Scott Euser
requested to merge
issue/ai-3477973:3477973-dynamically-load-tokenizer
into
1.1.x
8 months ago
Overview
0
Commits
10
Pipelines
11
Changes
5
Expand
Closes
#3477973
0
0
Merge request reports
Compare
1.1.x
version 10
b407e1f0
1 week ago
version 9
c341a488
1 week ago
version 8
a466e606
3 weeks ago
version 7
a466e606
3 weeks ago
version 6
7b418a42
4 months ago
version 5
10037d5c
8 months ago
version 4
db029acb
8 months ago
version 3
cf5363c8
8 months ago
version 2
c88363e1
8 months ago
version 1
ec829844
8 months ago
1.1.x (base)
and
latest version
latest version
aaebe3b9
10 commits,
5 days ago
version 10
b407e1f0
8 commits,
1 week ago
version 9
c341a488
7 commits,
1 week ago
version 8
a466e606
6 commits,
3 weeks ago
version 7
a466e606
65 commits,
3 weeks ago
version 6
7b418a42
5 commits,
4 months ago
version 5
10037d5c
5 commits,
8 months ago
version 4
db029acb
4 commits,
8 months ago
version 3
cf5363c8
3 commits,
8 months ago
version 2
c88363e1
2 commits,
8 months ago
version 1
ec829844
1 commit,
8 months ago
5 files
+
161
−
42
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
modules/ai_search/src/Backend/AiSearchBackendPluginBase.php
+
40
−
1
Options
@@ -3,9 +3,11 @@
namespace
Drupal\ai_search\Backend
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\ai\Utility\TokenizerInterface
;
use
Drupal\ai_search
\Trait\AiSearchBackendEmbeddingsEngineTrait
;
use
Drupal\ai_search
\Trait\AiSearchBackendEmbeddingsStrategyTrait
;
use
Drupal\search_api
\Backend\BackendPluginBase
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Base class for Search API AI backend plugins.
@@ -21,6 +23,43 @@ abstract class AiSearchBackendPluginBase extends BackendPluginBase {
use
AiSearchBackendEmbeddingsEngineTrait
;
use
AiSearchBackendEmbeddingsStrategyTrait
;
/**
* Constructs an AiSearchBackendPluginBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\ai\Utility\TokenizerInterface $tokenizer
* The tokenizer.
*/
public
function
__construct
(
array
$configuration
,
string
$plugin_id
,
array
$plugin_definition
,
protected
TokenizerInterface
$tokenizer
,
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
$tokenizer
=
$container
->
get
(
'ai.tokenizer'
);
$plugin
=
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$tokenizer
);
/** @var \Drupal\Core\StringTranslation\TranslationInterface $translation */
$translation
=
$container
->
get
(
'string_translation'
);
$plugin
->
setStringTranslation
(
$translation
);
$plugin
->
setFieldsHelper
(
$container
->
get
(
'search_api.fields_helper'
));
$plugin
->
setMessenger
(
$container
->
get
(
'messenger'
));
$plugin
->
tokenizer
=
$container
->
get
(
'ai.tokenizer'
);
return
$plugin
;
}
/**
* {@inheritdoc}
*/
@@ -54,7 +93,7 @@ abstract class AiSearchBackendPluginBase extends BackendPluginBase {
// Build the form for both types.
return
array_merge
(
$this
->
engineConfigurationForm
(
$form
,
$form_state
),
$this
->
engineConfigurationForm
(
$form
,
$form_state
,
$this
->
tokenizer
),
$this
->
strategyConfigurationForm
(
$form
,
$form_state
)
);
}
Loading