diff --git a/core/llm/llms/Bedrock.test.ts b/core/llm/llms/Bedrock.test.ts index d39246fa5..49ea394c7 100644 --- a/core/llm/llms/Bedrock.test.ts +++ b/core/llm/llms/Bedrock.test.ts @@ -1,5 +1,5 @@ import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime"; -import { fromIni } from "@aws-sdk/credential-providers"; +import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; import Bedrock from "./Bedrock.js"; import { ChatMessage, Chunk, CompletionOptions, UserChatMessage } from "../../index.js"; @@ -15,7 +15,7 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => ({ // Mock credential provider jest.mock("@aws-sdk/credential-providers", () => ({ - fromIni: jest.fn().mockImplementation(() => async () => ({ + fromNodeProviderChain: jest.fn().mockImplementation(() => async () => ({ accessKeyId: "test-access-key", secretAccessKey: "test-secret-key", sessionToken: "test-session-token", diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index aa15997ad..f49eaafea 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -3,7 +3,7 @@ import { ConverseStreamCommand, InvokeModelCommand, } from "@aws-sdk/client-bedrock-runtime"; -import { fromIni } from "@aws-sdk/credential-providers"; +import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; import { ChatMessage, @@ -328,7 +328,7 @@ class Bedrock extends BaseLLM { private async _getCredentials() { try { - return await fromIni({ + return await fromNodeProviderChain({ profile: this.profile, ignoreCache: true, })(); @@ -336,7 +336,7 @@ class Bedrock extends BaseLLM { console.warn( `AWS profile with name ${this.profile} not found in ~/.aws/credentials, using default profile`, ); - return await fromIni()(); + return await fromNodeProviderChain()(); } } diff --git a/core/llm/llms/BedrockImport.ts b/core/llm/llms/BedrockImport.ts index 45ef554a6..e74fb5064 100644 --- a/core/llm/llms/BedrockImport.ts +++ b/core/llm/llms/BedrockImport.ts @@ -1,8 +1,8 @@ import { - BedrockRuntimeClient, - InvokeModelWithResponseStreamCommand, + BedrockRuntimeClient, + InvokeModelWithResponseStreamCommand, } from "@aws-sdk/client-bedrock-runtime"; -import { fromIni } from "@aws-sdk/credential-providers"; +import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; import { CompletionOptions, LLMOptions } from "../../index.js"; import { BaseLLM } from "../index.js"; @@ -77,7 +77,7 @@ class BedrockImport extends BaseLLM { private async _getCredentials() { try { - return await fromIni({ + return await fromNodeProviderChain({ profile: this.profile, ignoreCache: true, })(); @@ -85,7 +85,7 @@ class BedrockImport extends BaseLLM { console.warn( `AWS profile with name ${this.profile} not found in ~/.aws/credentials, using default profile`, ); - return await fromIni()(); + return await fromNodeProviderChain()(); } } } diff --git a/core/llm/llms/SageMaker.ts b/core/llm/llms/SageMaker.ts index 1f11d41ea..c9d14533c 100644 --- a/core/llm/llms/SageMaker.ts +++ b/core/llm/llms/SageMaker.ts @@ -1,9 +1,9 @@ import { - InvokeEndpointCommand, - InvokeEndpointWithResponseStreamCommand, - SageMakerRuntimeClient, + InvokeEndpointCommand, + InvokeEndpointWithResponseStreamCommand, + SageMakerRuntimeClient, } from "@aws-sdk/client-sagemaker-runtime"; -import { fromIni } from "@aws-sdk/credential-providers"; +import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; // @ts-ignore import jinja from "jinja-js"; @@ -130,14 +130,14 @@ class SageMaker extends BaseLLM { private async _getCredentials() { try { - return await fromIni({ + return await fromNodeProviderChain({ profile: this.profile, })(); } catch (e) { console.warn( `AWS profile with name ${this.profile} not found in ~/.aws/credentials, using default profile`, ); - return await fromIni()(); + return await fromNodeProviderChain()(); } }