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
!33
Add empty option
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add empty option
issue/ai-3465121:3465121-default-model
into
1.0.x
Overview
2
Commits
3
Pipelines
4
Changes
1
Merged
Scott Euser
requested to merge
issue/ai-3465121:3465121-default-model
into
1.0.x
10 months ago
Overview
2
Commits
3
Pipelines
4
Changes
1
Expand
Closes
#3465121
0
0
Merge request reports
Compare
1.0.x
version 2
40e2a04f
9 months ago
version 1
4e40cef7
10 months ago
1.0.x (base)
and
latest version
latest version
051cd9f5
3 commits,
8 months ago
version 2
40e2a04f
2 commits,
9 months ago
version 1
4e40cef7
1 commit,
10 months ago
1 file
+
23
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Form/AiSettingsForm.php
+
23
−
1
Options
@@ -165,7 +165,7 @@ class AiSettingsForm extends ConfigFormBase {
'#title'
=>
$this
->
t
(
'Default Model'
),
'#default_value'
=>
$default_providers
[
$operation_type
[
'id'
]][
'model_id'
]
??
''
,
'#options'
=>
$models
,
'#empty_option'
=>
$this
->
t
(
'
No available models
'
),
'#empty_option'
=>
$this
->
t
(
'
- Select -
'
),
];
}
}
@@ -173,6 +173,28 @@ class AiSettingsForm extends ConfigFormBase {
return
parent
::
buildForm
(
$form
,
$form_state
);
}
/**
* {@inheritdoc}
*/
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
parent
::
validateForm
(
$form
,
$form_state
);
$values
=
$form_state
->
getValues
();
foreach
(
$this
->
providerManager
->
getOperationTypes
()
as
$operation_type
)
{
// If a provider is selected, a model must also be selected.
if
(
!
empty
(
$values
[
'operation__'
.
$operation_type
[
'id'
]])
&&
empty
(
$values
[
'model__'
.
$operation_type
[
'id'
]])
)
{
$message
=
$this
->
t
(
'You have selected a provider for @operation but have not selected a model.'
,
[
'@operation'
=>
$operation_type
[
'label'
],
]);
$form_state
->
setErrorByName
(
'model__'
.
$operation_type
[
'id'
],
$message
);
}
}
}
/**
* {@inheritdoc}
*/
Loading