diff --git a/lib/Service/WatsonxAPIService.php b/lib/Service/WatsonxAPIService.php index 4e7ef51f..1e4787c5 100644 --- a/lib/Service/WatsonxAPIService.php +++ b/lib/Service/WatsonxAPIService.php @@ -106,10 +106,7 @@ public function getModels(string $userId): array { try { $this->logger->debug('Actually getting watsonx.ai models with a network request'); - $params = [ - 'version' => Application::WATSONX_API_VERSION, - ]; - $modelsResponse = $this->request($userId, '/ml/v1/foundation_model_specs', $params); + $modelsResponse = $this->request($userId, '/ml/v1/foundation_model_specs?version=' . Application::WATSONX_API_VERSION); } catch (Exception $e) { $this->logger->warning('Error retrieving models (exc): ' . $e->getMessage()); $this->areCredsValid = false; @@ -771,7 +768,7 @@ public function requestIAM(array $params = [], string $method = 'POST'): array { $paramsContent = http_build_query($params); $url .= '?' . $paramsContent; } else { - $options['body'] = $params; + $options['body'] = $this->watsonxSettingsService->isUsingIbmCloud() ? $params : json_encode($params); } } diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 3c73670e..24759e21 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -410,6 +410,7 @@ import { confirmPassword } from '@nextcloud/password-confirmation' import { generateUrl } from '@nextcloud/router' import debounce from 'debounce' +const API_VERSION = '2024-03-14' const DEFAULT_MODEL_ITEM = { id: 'Default', value: 'Default', label: 'Default' } export default { @@ -452,9 +453,9 @@ export default { computed: { modelEndpointUrl() { if (this.state.url === '') { - return 'https://us-south.ml.cloud.ibm.com/ml/v1/foundation_model_specs' + return 'https://us-south.ml.cloud.ibm.com/ml/v1/foundation_model_specs?version=' + API_VERSION } - return this.state.url.replace(/\/*$/, '/ml/v1/foundation_model_specs') + return this.state.url.replace(/\/*$/, '/ml/v1/foundation_model_specs?version=' + API_VERSION) }, configured() { return !!this.state.api_key && (this.isUsingIbmCloud || !!this.state.username)