Skip to content

Commit

Permalink
Remove default credential provider
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisTraub committed Mar 20, 2024
1 parent 2ec21c1 commit cde4608
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 59 deletions.
6 changes: 1 addition & 5 deletions javascriptv3/example_code/bedrock-runtime/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { fileURLToPath } from "url";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -36,10 +35,7 @@ const hello = async () => {
console.log("Invoking model...\n");

// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
credentialDefaultProvider: defaultProvider,
region: AWS_REGION,
});
const client = new BedrockRuntimeClient({ region: AWS_REGION });

// Prepare the payload for the model.
const payload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -29,10 +28,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Jurassic-2 Mid if not provided.
modelId = modelId || "ai21.j2-mid-v1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -23,10 +22,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Titan Text G1 - Express if not provided.
modelId = modelId || "amazon.titan-text-express-v1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand Down Expand Up @@ -36,10 +35,7 @@ import {
*/
export const invokeMessagesApi = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude 2.0 if not provided.
modelId = modelId || "anthropic.claude-v2";
Expand Down Expand Up @@ -82,10 +78,7 @@ export const invokeMessagesApi = async (prompt, modelId) => {
*/
export const invokeTextCompletionsApi = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude 2.0 if not provided.
modelId = modelId || "anthropic.claude-v2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand Down Expand Up @@ -41,10 +40,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude 3 Haiku if not provided.
modelId = modelId || "anthropic.claude-3-haiku-20240307-v1:0";
Expand Down Expand Up @@ -87,10 +83,7 @@ export const invokeModel = async (prompt, modelId) => {
*/
export const invokeModelWithResponseStream = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude 3 Haiku if not provided.
modelId = modelId || "anthropic.claude-3-haiku-20240307-v1:0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand Down Expand Up @@ -34,10 +33,7 @@ import {
*/
export const invokeMessagesApi = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude Instant 1.0 if not provided.
modelId = modelId || "anthropic.claude-instant-v1";
Expand Down Expand Up @@ -80,10 +76,7 @@ export const invokeMessagesApi = async (prompt, modelId) => {
*/
export const invokeTextCompletionsApi = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Claude Instant 1.0 if not provided.
modelId = modelId || "anthropic.claude-instant-v1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -23,10 +22,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Llama2 Chat 13B if not provided.
modelId = modelId || "meta.llama2-13b-chat-v1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -26,10 +25,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Mistral 7B Instruct if not provided.
modelId = modelId || "mistral.mistral-7b-instruct-v0:2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { fileURLToPath } from "url";

import { FoundationModels } from "../../config/foundation_models.js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import {
BedrockRuntimeClient,
InvokeModelCommand,
Expand All @@ -26,10 +25,7 @@ import {
*/
export const invokeModel = async (prompt, modelId) => {
// Create a new Bedrock Runtime client instance.
const client = new BedrockRuntimeClient({
region: "us-east-1",
credentialDefaultProvider: defaultProvider,
});
const client = new BedrockRuntimeClient({ region: "us-east-1" });

// Use the provided model ID or fallback to Mistral 8x7B Instruct if not provided.
modelId = modelId || "mistral.mixtral-8x7b-instruct-v0:1";
Expand Down
3 changes: 1 addition & 2 deletions javascriptv3/example_code/bedrock-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"integration-test": "vitest run **/*.integration.test.js"
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.533.0",
"@aws-sdk/credential-provider-node": "^3.533.0"
"@aws-sdk/client-bedrock-runtime": "^3.533.0"
},
"devDependencies": {
"vitest": "^1.3.0",
Expand Down

0 comments on commit cde4608

Please sign in to comment.