Use fetchwithRequestOptions for all calls in WatsonX.

Signed-off-by: Łukasz Dywicki <luke@code-house.org>
This commit is contained in:
Łukasz Dywicki 2025-03-25 21:33:53 +04:00
parent a2634fb22a
commit 075b785e19

View file

@ -21,7 +21,7 @@ class WatsonX extends BaseLLM {
if (this.apiBase?.includes("cloud.ibm.com")) {
// watsonx SaaS
const wxToken = await (
await fetch(
await this.fetch(
`https://iam.cloud.ibm.com/identity/token?apikey=${this.apiKey}&grant_type=urn:ibm:params:oauth:grant-type:apikey`,
{
method: "POST",
@ -48,7 +48,7 @@ class WatsonX extends BaseLLM {
// Using username/password auth
const userPass = this.apiKey?.split(":");
const wxToken = await (
await fetch(`${this.apiBase}/icp4d-api/v1/authorize`, {
await this.fetch(`${this.apiBase}/icp4d-api/v1/authorize`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@ -61,7 +61,7 @@ class WatsonX extends BaseLLM {
})
).json();
const wxTokenExpiry = await (
await fetch(`${this.apiBase}/usermgmt/v1/user/tokenExpiry`, {
await this.fetch(`${this.apiBase}/usermgmt/v1/user/tokenExpiry`, {
method: "GET",
headers: {
Accept: "application/json",