File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,12 @@ public function getModels(string $userId): array {
9292 $ modelsResponse = $ this ->request ($ userId , 'models ' );
9393 $ this ->logger ->debug ('Actually getting OpenAI models with a network request ' );
9494 if (!isset ($ modelsResponse ['data ' ])) {
95- $ this ->logger ->warning ('Error retrieving models: ' . json_encode ($ modelsResponse ));
96- throw new Exception ($ this ->l10n ->t ('Unknown models error ' ), Http::STATUS_INTERNAL_SERVER_ERROR );
95+ if (!is_array ($ modelsResponse )) {
96+ $ this ->logger ->warning ('Error retrieving models: ' . json_encode ($ modelsResponse ));
97+ throw new Exception ($ this ->l10n ->t ('Unknown models error ' ), Http::STATUS_INTERNAL_SERVER_ERROR );
98+ }
99+ // also consider responses without 'data' as valid
100+ $ modelsResponse = ['data ' => $ modelsResponse ];
97101 }
98102 $ cache ->set ($ cacheKey , $ modelsResponse , Application::MODELS_CACHE_TTL );
99103 $ this ->modelsMemoryCache = $ modelsResponse ;
You can’t perform that action at this time.
0 commit comments