File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -91,10 +91,15 @@ public function getModels(string $userId): array {
9191
9292 $ modelsResponse = $ this ->request ($ userId , 'models ' );
9393 $ this ->logger ->debug ('Actually getting OpenAI models with a network request ' );
94- if (! isset ($ modelsResponse ['data ' ])) {
94+ if (isset ($ modelsResponse ['error ' ])) {
9595 $ this ->logger ->warning ('Error retrieving models: ' . json_encode ($ modelsResponse ));
9696 throw new Exception ($ this ->l10n ->t ('Unknown models error ' ), Http::STATUS_INTERNAL_SERVER_ERROR );
9797 }
98+
99+ if (!isset ($ modelsResponse ['data ' ])) {
100+ // also consider responses without 'data' as valid
101+ $ modelsResponse = ['data ' => $ modelsResponse ];
102+ }
98103 $ cache ->set ($ cacheKey , $ modelsResponse , Application::MODELS_CACHE_TTL );
99104 $ this ->modelsMemoryCache = $ modelsResponse ;
100105 return $ modelsResponse ;
You can’t perform that action at this time.
0 commit comments