@@ -240,19 +240,46 @@ const ApiOptions = ({
240240 ) {
241241 vscode . postMessage ( { type : "requestRouterModels" } )
242242 } else if ( selectedProvider === "ibm-watsonx" ) {
243- vscode . postMessage ( {
244- type : "requestWatsonxModels" ,
245- values : {
246- apiKey : apiConfiguration . watsonxApiKey ,
247- projectId : apiConfiguration . watsonxProjectId ,
248- platform : apiConfiguration . watsonxPlatform ,
249- baseUrl : apiConfiguration . watsonxBaseUrl ,
250- authType : apiConfiguration . watsonxAuthType ,
251- username : apiConfiguration . watsonxUsername ,
252- password : apiConfiguration . watsonxPassword ,
253- region : apiConfiguration . watsonxRegion ,
254- } ,
255- } )
243+ const {
244+ watsonxPlatform,
245+ watsonxApiKey,
246+ watsonxProjectId,
247+ watsonxBaseUrl,
248+ watsonxAuthType,
249+ watsonxUsername,
250+ watsonxPassword,
251+ watsonxRegion,
252+ } = apiConfiguration
253+
254+ const ibmCloudReady =
255+ watsonxPlatform === "ibmCloud" && ! ! watsonxApiKey && ! ! watsonxProjectId && ! ! watsonxRegion
256+
257+ const cloudPakReady =
258+ watsonxPlatform === "cloudPak" &&
259+ ! ! watsonxBaseUrl &&
260+ ! ! watsonxProjectId &&
261+ ! ! watsonxUsername &&
262+ ( ( watsonxAuthType === "apiKey" && ! ! watsonxApiKey ) ||
263+ ( watsonxAuthType === "password" && ! ! watsonxPassword ) )
264+
265+ if ( ibmCloudReady || cloudPakReady ) {
266+ vscode . postMessage ( {
267+ type : "requestWatsonxModels" ,
268+ values : {
269+ apiKey : apiConfiguration . watsonxApiKey ,
270+ projectId : apiConfiguration . watsonxProjectId ,
271+ platform : apiConfiguration . watsonxPlatform ,
272+ baseUrl :
273+ apiConfiguration . watsonxPlatform === "ibmCloud"
274+ ? undefined
275+ : apiConfiguration . watsonxBaseUrl ,
276+ authType : apiConfiguration . watsonxAuthType ,
277+ username : apiConfiguration . watsonxUsername ,
278+ password : apiConfiguration . watsonxPassword ,
279+ region : apiConfiguration . watsonxRegion ,
280+ } ,
281+ } )
282+ }
256283 }
257284 } ,
258285 250 ,
0 commit comments