Fix config array default causing driver resolution failure#327
Draft
JoshSalway wants to merge 2 commits intolaravel:0.xfrom
Draft
Fix config array default causing driver resolution failure#327JoshSalway wants to merge 2 commits intolaravel:0.xfrom
JoshSalway wants to merge 2 commits intolaravel:0.xfrom
Conversation
When ai.default is an array (e.g. ['text' => 'anthropic']), the manager crashed because it expected a string. Now extracts the 'text' key from array defaults, falls back to first value, and throws helpful errors for invalid configurations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The AiManager fix only covered the Ai::textProvider() path. The
Promptable::getProvidersAndModels() path also reads config('ai.default')
directly and passes it to formatProviderAndModelList(), which would
interpret ['text' => 'anthropic'] as provider='text' model='anthropic'.
This normalizes the array config in Promptable before passing it to
formatProviderAndModelList. Also adds tests for Promptable path,
integer-indexed arrays, and multi-generation-type configs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
When
config('ai.default')is an array (e.g.['text' => 'anthropic']), the manager and promptable layer both fail to resolve the provider name correctly, causing "Instance driver [text] is not supported".Handles array configs by extracting the relevant key in both
AiManager::getDefaultInstance()andPromptable::getProvidersAndModels().Fixes #289
Test plan
config('ai.default')to an array like['text' => 'anthropic']and verifyAiManager::getDefaultInstance()resolves the correct provider name instead of throwing "Instance driver [text] is not supported"config('ai.default')to a plain string like'anthropic'and verify existing behavior is unchangedPromptable::getProvidersAndModels()correctly extracts provider names from both string and array default configsphp artisan test