Issue #3586500: Get default Vdb provider if none yet selected
Description
Following the defaultIfNone logic from AiProviderPluginManager, I have created the same method in AiVdbProviderPluginManager. The only difference is that there is only 1 parameter: preferred provider. Having the parameter allows the provider modules to make their provider default in case none is already select during the setup of their provider, for example in submitForm, the same way it is done in docs/examples/dropai_provider/src/Form/DropAiConfigForm.php (but for ai provider).
If no preferred provider is passed, the first provider in the list that is setup will be returned and be set as default, so in the future the value is taken from the config instead.
Testing instructions
- Checkout this branch with the fix.
- Install any ai provider that supports embeddings.
- Make sure this provider is selected as default for operation type "Embeddings" here
/admin/config/ai/settings - Install any vdb provider. Do not change any AI settings. Make sure that here
/admin/config/ai/settingsnone "Vector Database (VDB) Providers" is selected. - Try to apply this recipe https://www.drupal.org/project/ai_recipe_image_search_vector .
- See that the Search API server was created with the installed provider.
Checklist
- I have linked the related issue in the MR title or description
- I have performed a self-review of my own code
- I have added or updated tests, or explained in the description why this change is not covered by tests
- I have updated documentation for any new or changed functionality
- I have written testing instructions and verified them locally
- I have noted any required post-merge steps (config imports, cache rebuilds, manual changes)
- This MR contains no breaking API or hook changes, or they are explicitly documented in the description
AI Compliance
Note
Check the one that best describes your usage, or leave all unchecked if AI was not significantly used.
-
AI Assisted Code
Mainly written by a human; AI used for autocomplete or partial generation under full human supervision. -
AI Generated Code
Mainly generated by AI, reviewed and approved by a human before this MR was created. -
Vibe Coded
Generated by AI and only functionally reviewed before this MR was created.
Closes #3586500