@@ -114,11 +114,15 @@ public function getProviderClassName(string $id): string
114
114
*/
115
115
public function isProviderConfigured (string $ idOrClassName ): bool
116
116
{
117
- $ instance = $ this ->getProviderInstance ($ idOrClassName );
118
-
119
- // TODO: Call availability() method when ProviderInterface is available
120
- // For now, assume configured if we can instantiate
121
- return $ instance !== null ;
117
+ try {
118
+ $ this ->getProviderInstance ($ idOrClassName );
119
+
120
+ // TODO: Call availability() method when ProviderInterface is available
121
+ // For now, assume configured if we can instantiate without exception
122
+ return true ;
123
+ } catch (InvalidArgumentException $ e ) {
124
+ return false ;
125
+ }
122
126
}
123
127
124
128
/**
@@ -136,8 +140,20 @@ public function findModelsMetadataForSupport(ModelRequirements $modelRequirement
136
140
foreach ($ this ->providerClassNames as $ providerId => $ className ) {
137
141
$ providerResults = $ this ->findProviderModelsMetadataForSupport ($ providerId , $ modelRequirements );
138
142
if (!empty ($ providerResults )) {
143
+ $ providerInstance = $ this ->getProviderInstance ($ providerId );
144
+
145
+ // Validate that provider has metadata method
146
+ if (!method_exists ($ providerInstance , 'metadata ' )) {
147
+ continue ;
148
+ }
149
+
150
+ $ providerMetadata = $ providerInstance ->metadata ();
151
+ if (!$ providerMetadata instanceof ProviderMetadata) {
152
+ continue ;
153
+ }
154
+
139
155
$ results [] = new ProviderModelsMetadata (
140
- $ this -> getProviderInstance ( $ providerId )-> metadata () ,
156
+ $ providerMetadata ,
141
157
$ providerResults
142
158
);
143
159
}
@@ -173,21 +189,14 @@ public function findProviderModelsMetadataForSupport(
173
189
*
174
190
* @param string $idOrClassName The provider ID or class name.
175
191
* @param string $modelId The model identifier.
176
- * @param ModelConfig|array<string, mixed> $modelConfig The model configuration.
192
+ * @param ModelConfig $modelConfig The model configuration.
177
193
* @return object The configured model instance.
178
194
* @throws InvalidArgumentException If provider or model is not found.
179
195
*/
180
- public function getProviderModel (string $ idOrClassName , string $ modelId , $ modelConfig ): object
196
+ public function getProviderModel (string $ idOrClassName , string $ modelId , ModelConfig $ modelConfig ): object
181
197
{
182
198
$ instance = $ this ->getProviderInstance ($ idOrClassName );
183
199
184
- // Normalize config to ModelConfig if needed
185
- if (is_array ($ modelConfig )) {
186
- // TODO: Improve type safety when ModelConfig::fromArray is finalized
187
- /** @var ModelConfig $modelConfig */
188
- $ modelConfig = ModelConfig::fromArray ($ modelConfig );
189
- }
190
-
191
200
// TODO: Call model() method when ProviderInterface is available
192
201
throw new InvalidArgumentException ('Model instantiation not yet implemented ' );
193
202
}
0 commit comments