Skip to content

Commit 95de5f1

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Service/OpenAiAPIService.php

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

0 commit comments

Comments
 (0)