Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/Service/OpenAiAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,15 @@ public function getModels(string $userId): array {
$this->areCredsValid = false;
throw $e;
}
if (!isset($modelsResponse['data'])) {
if (isset($modelsResponse['error'])) {
$this->logger->warning('Error retrieving models: ' . \json_encode($modelsResponse));
$this->areCredsValid = false;
throw new Exception($this->l10n->t('Unknown models error'), Http::STATUS_INTERNAL_SERVER_ERROR);
throw new Exception($modelsResponse['error'], Http::STATUS_INTERNAL_SERVER_ERROR);
}

if (!isset($modelsResponse['data'])) {
// also consider responses without 'data' as valid
$modelsResponse = ['data' => $modelsResponse];
}
$cache->set($cacheKey, $modelsResponse, Application::MODELS_CACHE_TTL);
$this->modelsMemoryCache = $modelsResponse;
Expand Down