Skip to content

Commit ebcc26f

Browse files
committed
feat: add support for together ai
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent dc4cc4d commit ebcc26f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Service/OpenAiAPIService.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)