Repository navigation
fix(magic-ai): pre-select the newest PIM-capable models on fetch - #724
Merged
navneetkumar-pim-webkul merged 1 commit intoSep 24, 2026
Merged
Conversation
Model discovery kept only the ids and sorted them alphabetically, so the auto-selection on the Add AI Platform form ticked legacy models such as five gpt-3.5-turbo variants, and the connection test pinged Gemini image models or models the provider no longer serves to the account. - keep the release timestamp each provider reports and rank by it, with the version in the model name as the fallback for providers without one - pre-select the newest text models for chat, generation and the agent plus the newest image model, one per family - list only Gemini models that support generateContent or predict, and drop legacy fine-tunes, completion-only, search and speech models - try up to three ticked text models before a connection test fails
Copilot started reviewing on behalf of
navneetkumar-pim-webkul
September 24, 2026 14:44
View session
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Address Azure release timestamps, context-window family normalization, and filtering of non-chat models from retry candidates.
Review effort: Lite
Findings: None
What changed in this PR
Updates Magic AI model discovery and selection to prefer current, usable models and retry connection tests across multiple text models.
Changes:
- Adds provider release metadata and filters unsupported models.
- Improves ranking, family deduplication, and image-model selection.
- Adds connection-test fallback attempts and related coverage.
| File | Description |
|---|---|
packages/Webkul/MagicAI/tests/Unit/AiProviderTest.php |
Tests discovery metadata and Gemini filtering. |
packages/Webkul/MagicAI/tests/Feature/PlatformConnectionTest.php |
Tests connection fallback behavior. |
packages/Webkul/MagicAI/src/Support/ModelRecommender.php |
Implements filtering, ranking, deduplication, and text selection. |
packages/Webkul/MagicAI/src/Enums/AiProvider.php |
Adds catalog metadata and provider filtering. |
packages/Webkul/AiAgent/tests/Unit/ModelSelectionConfigTest.php |
Updates recommendation expectations. |
packages/Webkul/AiAgent/tests/Unit/ModelRecommenderTest.php |
Covers ranking and filtering scenarios. |
packages/Webkul/AiAgent/Resources/views/components/chat-widget.blade.php |
Recognizes Gemini image models. |
packages/Webkul/Admin/src/Http/Controllers/MagicAI/MagicAIPlatformController.php |
Adds connection-test fallback logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
navneetkumar-pim-webkul
deleted the
fix/magic-ai-recommend-latest-models
branch
September 24, 2026 15:02
2 of 6 tasks
navneetkumar-pim-webkul
added a commit
that referenced
this pull request
Sep 24, 2026
Six merged pull requests since v3.1.1 carried no changelog entry: the gallery unsaved badge and worker timeout handler (#713), the import filter re-render (#720), the worker timeout alarm (#722), the channel name on PostgreSQL (#725), the price input height (#726), and the export view events (#717, #718). The two fixes pending in #727 and #728 are included so the cut merges after them. The model recommendation entry described the cheap-tier ranking that #724 replaced with newest-per-family; it now describes the shipped behaviour. 3.1.2 is a patch release, so everything is filed under bug fixes and improvements; no feature section. Core::VERSION, package.json and the UPGRADE.md walkthrough move to 3.1.2 together, as they did for 3.1.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Reference
No issue filed. Found while adding Gemini, OpenAI, Mistral and xAI platforms: the form pre-selected legacy or unusable models and the connection test failed on a valid key.
Description
Model discovery kept only model ids and sorted them alphabetically, so after Fetch models the form ticked e.g.
gpt-3.5-turbo,-0125,-1106,-16k,-instruct; Gemini image models; andmistral-small-2603next tomistral-small-latestplusvoxtralspeech models. The connection test then pinged the first ticked model and failed (Gemini 404 "no longer available to new users", or a 429).AiProvider): keeps the release timestamp each API reports (created/created_at/ Ollamamodified_at) via the newfetchModelCatalog();discoverModels()gains an additivereleasedkey. Gemini is filtered bysupportedGenerationMethods(generateContent/predict), which drops embedding andaqamodels.fetchModels()still returns sorted ids, so existing callers keep working.ModelRecommender::recommend): newest first by release date, with the version in the name as fallback (gemini-3.7 > 3.1 > 2.5), and the cost-effective tier within a generation. One model per family (the-latestalias wins). Picks the newest text models for chat, generation and the AI agent, plus one image model.curie:ft-*fine-tunes,*-instruct,*-search-*,aqaandvoxtral. Gemini*-imagemodels count as image models for the connection-test picker and the chat widget's JS copy of the list.How To Test This?
gpt-5-mini,gpt-5,gpt-4.1-mini,gpt-4o-mini) plus one image model.gpt-3.5-*. Not listed:curie:ft-*.*-imagemodel, andaqa/ embedding models are not listed.mistral-small-latestis selected once (no-2603duplicate), and novoxtralmodel is selected.gemini-2.5-flash), then a current one, and click Test Connection. It succeeds via the fallback.vendor/bin/pest packages/Webkul/AiAgent/tests/Unit packages/Webkul/MagicAI/tests packages/Webkul/Admin/tests/Feature/MagicAi packages/Webkul/Admin/tests/Feature/MagicAIScreenshots
N/A — only the server response changes: the fetched list and which models are pre-selected.
Checklist
vendor/bin/pestpasses locally (AiAgent Unit, MagicAI, Admin Magic AI suites: 684 passed)vendor/bin/pint --testreports no style issuesunopim:translations:checkpasses)3.xAlso run: PHPStan on the changed files (no errors) and Rector dry-run (suggestions applied to new lines). Playwright was not run.
Existing tests updated for the intended behaviour: one pre-selected image model instead of all of them,
-instructexcluded, newest generation ranked before the cheaper older tier, and the additivereleasedkey.Documentation