Skip to content

Commit

Permalink
Merge pull request #895 from Portkey-AI/chore/streamline-bedrock-plug…
Browse files Browse the repository at this point in the history
…in-naming

chore: streamline bedrock plugin creds naming convention
  • Loading branch information
VisargD authored Jan 28, 2025
2 parents 3ba12e8 + a182014 commit 24bc353
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
12 changes: 6 additions & 6 deletions plugins/bedrock/bedrock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ describe('Credentials check', () => {
};
const parameters: PluginParameters<BedrockParameters['credentials']> = {
credentials: {
accessKeyId: '',
accessKeySecret: '',
region: '',
awsAccessKeyId: '',
awsSecretAccessKey: '',
awsRegion: '',
},
guardrailId: '',
guardrailVersion: '',
Expand Down Expand Up @@ -72,9 +72,9 @@ describe('Credentials check', () => {
};
const parameters: PluginParameters<BedrockParameters['credentials']> = {
credentials: {
accessKeyId: 'accessKeyID',
region: 'us-east-1',
accessKeySecret: 'accessKeySecret',
awsAccessKeyId: 'accessKeyID',
awsRegion: 'us-east-1',
awsSecretAccessKey: 'accessKeySecret',
},
guardrailId: 'guardrailID',
guardrailVersion: 'guardrailVersion',
Expand Down
6 changes: 5 additions & 1 deletion plugins/bedrock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
import { BedrockBody, BedrockParameters } from './type';
import { bedrockPost, redactPii } from './util';

const REQUIRED_CREDENTIAL_KEYS = ['accessKeyId', 'accessKeySecret', 'region'];
const REQUIRED_CREDENTIAL_KEYS = [
'awsAccessKeyId',
'awsSecretAccessKey',
'awsRegion',
];

export const validateCreds = (
credentials?: BedrockParameters['credentials']
Expand Down
6 changes: 3 additions & 3 deletions plugins/bedrock/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export interface BedrockResponse {

export interface BedrockParameters {
credentials: {
accessKeyId: string;
accessKeySecret: string;
awsAccessKeyId: string;
awsSecretAccessKey: string;
awsSessionToken?: string;
region: string;
awsRegion: string;
};
guardrailVersion: string;
guardrailId: string;
Expand Down
8 changes: 4 additions & 4 deletions plugins/bedrock/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const bedrockPost = async (
credentials: Record<string, string>,
body: BedrockBody
) => {
const url = `https://bedrock-runtime.${credentials?.region}.amazonaws.com/guardrail/${credentials?.guardrailId}/version/${credentials?.guardrailVersion}/apply`;
const url = `https://bedrock-runtime.${credentials?.awsRegion}.amazonaws.com/guardrail/${credentials?.guardrailId}/version/${credentials?.guardrailVersion}/apply`;

const headers = await generateAWSHeaders(
body,
Expand All @@ -61,9 +61,9 @@ export const bedrockPost = async (
url,
'POST',
'bedrock',
credentials?.region ?? 'us-east-1',
credentials?.accessKeyId!,
credentials?.accessKeySecret!,
credentials?.awsRegion ?? 'us-east-1',
credentials?.awsAccessKeyId!,
credentials?.awsSecretAccessKey!,
credentials?.awsSessionToken || ''
);

Expand Down

0 comments on commit 24bc353

Please sign in to comment.