Address roomote feedback for better error handling

This commit is contained in:
Prasang Prajapati 2025-09-18 15:22:53 -04:00
parent ea2408fa26
commit 1a8239cf08

View file

@ -167,13 +167,8 @@ export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHa
if (!response?.result?.choices?.[0]?.message?.content) {
throw new Error("Invalid or empty response from IBM watsonx API")
}
// Extract the message content directly
return response.result.choices[0].message.content
} catch (error) {
if (error instanceof Error) {
throw new Error(`IBM watsonx completion error: ${error.message}`)
}
throw new Error(`IBM watsonx completion error: ${error.message}`)
}
}